Closed toniton closed 7 years ago
I never tried connecting to a sails server before with it but i'll run some tests
Do you have any debug info to share?
@db3dev on connect error just returns null
Hello Toniton,
Im using sailsJs too and I got connected. It is a bit tricky but feasible.
To do it you should send 3 query headers:
const headersQuery = '__sails_io_sdk_version=' + '0.13.6' + '&' + '__sails_io_sdk_platform=' + 'browser' + '&' + '__sails_io_sdk_language=' + 'javascript';
If sails do not found those it will deny the request. Also you do need to send the cookie id somewhere, but as Im not using cookies, Im using a token I needed to some additional workarounds.
query
should work fine now 😄
I'm having issues trying to use this library with sails server. I'm guessing the socket is closed before connection is established.
Here is an extract of my code
private socketIO: SocketIO;
private versionString: string;
static VERSION: string = "__sails_io_sdk_version";
static PLATFORM: string = "__sails_io_sdk_platform";
static LANGUAGE: string = "__sails_io_sdk_language";
constructor(private router: Router) { }
ngOnInit() {
this.generateVersionString(['0.11.0', 'android', 'java']);
console.log(this.versionString);
this.socketIO = new SocketIO('https://#####-####.c9users.io:1337', {
query: this.versionString,
useCORSRouteToGetCookie: false
});
this.socketIO.on('connect', function(data) {
console.log("hey....");
});
this.socketIO.on('connect_error', function(data) {
console.log('nawa ooooooo');
console.log(data);
});
this.socketIO.connect();
}
generateVersionString(sdkInfo: Array<string>): void {
this.versionString = LoginComponent.VERSION + "=" + sdkInfo[0] + "&" +
LoginComponent.PLATFORM + "=" + sdkInfo[1] + "&" +
LoginComponent.LANGUAGE + "=" + sdkInfo[2];
}