Socket.io Not Receive Msg from server -
i developing ios app using socket.io. msg sent server side properly.
but sent msg server client msg shows on terminal not showing in ios app log.
why socket.io don't receive event on ios log?.please me on this, in advance
server-side code var io = require('socket.io'), http = require('http'), server = http.createserver(), io = io.listen(server); io.on('connection', function(socket) { console.log('user connected'); socket.on('latitude', function(lat){ io.emit('latitude', lat); console.log('lats',lat); }); }); io.on('connection', function(socket) { socket.on('longitude', function(long){ socket.emit('longitude', long); console.log('longs',long); }); }); server.listen(3000, function(){ console.log('server started'); }) ios code _socketio = [[socketio alloc] init]; _socketio = [[socketio alloc] initwithdelegate:self]; [_socketio connecttohost:@"localhost" onport:3000]; - (void) socketiodidconnect:(socketio *)socket{ nslog(@"socket.io connected."); } - (void) socketio:(socketio *)socket didreceiveevent:(socketiopacket *)packet{ nslog(@"didreceiveevent()"); if([packet.name isequaltostring:@"longitude"]) { nsarray* args = packet.args; nsdictionary* arg = args[0]; [self addneweventwithnickname:arg[@"longitude"] andmessage:arg[@"longitude"]]; } } - (void) socketio:(socketio *)socket onerror:(nserror *)error { nslog(@"onerror() %@", error); } - (void) socketiodiddisconnect:(socketio *)socket disconnectedwitherror:(nserror *)error { nslog(@"socket.io disconnected. did error occur? %@", error); }
Comments
Post a Comment