We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am developing a application of two-way communication in SocketIO between App of iPhone and server.
I would like to implement the authentication function when connecting from the application side to the chat server.
I have implemented on the server side as described below.
io.set('authorization', function (handshakeData, callback) { var token = handshakeData.query.token; checkAuthToken(token, callback); });
However, I do not know where I should set the token in the app side.
var socket:SIOSocket! = nil SIOSocket.socketWithHost("ServerUrl" , response: { (_socket: SIOSocket!) in self.socket = _socket println(self.socket) self.socket.onConnect = {() in println("connected") } })
To borrow your wisdom.
The text was updated successfully, but these errors were encountered:
I use it in the connection block:
NSDictionary * parameters = [NSDictionary dictionaryWithObject:token forKey:@"token"]; NSArray * parametersArray = [NSArray arrayWithObject:parameters]; [SIOSocket socketWithHost:serverURL response: ^(SIOSocket *socket){ self.socket = socket; self.socket.onConnect = ^ () { if ([GabAuthenticatedUser sharedUser].token) { NSLog(@"SIOSocket : web socket connected. Authenticating with parameters : %@", parameters); [socket emit: @"authenticate" args:parametersArray]; } }; self.socket.onDisconnect = ^ () { NSLog(@"SIOSocket : web socket disconnected!"); }; self.socket.onError = ^(NSDictionary* error) { NSLog(@"SIOSocket : error connecting to web socket : %@", error); }; }];
Sorry, something went wrong.
An even more straightforward method that I personally used:
NSString *url = [NSString stringWithFormat:@"http://localhost:3000?token=%@",token]; [SIOSocket socketWithHost: url response: ^(SIOSocket *socketer) { ...
Works like a charm!
No branches or pull requests
I am developing a application of two-way communication in SocketIO between App of iPhone and server.
I would like to implement the authentication function when connecting from the application side to the chat server.
I have implemented on the server side as described below.
However, I do not know where I should set the token in the app side.
To borrow your wisdom.
The text was updated successfully, but these errors were encountered: