in Obj-C:
NSURL* url = [[NSURL alloc] initWithString:@"https://api.kubi.me:3000"];
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"forceWebsockets": @YES, @"forcePolling": @NO, @"log": @YES}];
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"socket connected");
}];
[socket on:@"command-send" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"SOCKET IO!!!");
}];
[socket on:@"message" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"SOCKET IO!!!");
}];
[socket connect];
server app.js:
io.sockets.on('connection',function(socket){
console.log('['+Date.now()/1000+'] Socket connected: ' + socket.id + ' ('+ socket.client.conn.transport.constr$
socket.on('channel',function(ch){
socket.join(ch);
});
socket.on('disconnect',function(){
console.log('['+Date.now()/1000+'] Socket disconnected: ' + socket.id + ' ('+ socket.client.conn.transport.co$
});
socket.on('command-request', function() {
io.emit('command-send');
console.log('Got a command request');
});
});
NSLog output:
2016-02-25 17:38:28.309 KubiDeviceSDKTestApp[5036:2357257] LOG SocketIOClient: Adding handler for event: connect
2016-02-25 17:38:28.310 KubiDeviceSDKTestApp[5036:2357257] LOG SocketIOClient: Adding handler for event: command-send
2016-02-25 17:38:28.310 KubiDeviceSDKTestApp[5036:2357257] LOG SocketIOClient: Adding handler for event: message
2016-02-25 17:38:28.310 KubiDeviceSDKTestApp[5036:2357257] LOG SocketIOClient: Adding engine
2016-02-25 17:38:28.313 KubiDeviceSDKTestApp[5036:2357257] LOG SocketEngine: Starting engine
2016-02-25 17:38:28.313 KubiDeviceSDKTestApp[5036:2357257] LOG SocketEngine: Handshaking
2016-02-25 17:38:28.319 KubiDeviceSDKTestApp[5036:2357257] LOG SocketIOClient: Client is being released
2016-02-25 17:38:28.320 KubiDeviceSDKTestApp[5036:2357257] LOG SocketEngine: Engine is being closed.
2016-02-25 17:38:28.320 KubiDeviceSDKTestApp[5036:2357257] LOG SocketEngine: Sending ws: as type: 1
2016-02-25 17:38:28.321 KubiDeviceSDKTestApp[5036:2357257] LOG SocketEngine: Engine is being released
Server app.js console.log output:
[1456450815.4] Socket connected: /#ZOs-ug3RuSqb0w1eAAAK (WebSocket)
[1456450815.405] Socket disconnected: /#ZOs-ug3RuSqb0w1eAAAK (WebSocket)
Somewhat stuck here and I'm not sure how to get any more logs about errors or what might be happening here...
99% sure it's because your socket isn't a property and is thus being released by ARC.
ah yes.. the n00bz...
iOS beginner here. If anyone can explain the solution, it will be really helpful.
@mayuroks If it's the same issue as this one, you should read up on ARC.
Most helpful comment
99% sure it's because your socket isn't a property and is thus being released by ARC.