nuclearace / Socket.IO-Client-Swift

socket.io-client for Swift
Other
361 stars 53 forks source link

socket.on:@"disconnect" callBack:(responceObject){} function not called on any auto disconnection #147

Open PrasannaYuvitime opened 6 years ago

PrasannaYuvitime commented 6 years ago

I am using socket.io for ios ,swift library and my socket disconnect listener not called on any auto disconnection while attempting infinite autoconnect....

self.socket = [[SocketIOClient alloc] initWithSocketURL:[NSURL URLWithString:[NSString stringWithFormat:kChatServer]]
                                             config:@{@"log": @YES,@"connectParams": @{@"Authorization":strToken}}];

self.socket.reconnects = true;
self.socket.reconnectWait = 5;
[self.socket connect];

//Socket disconnected
[self.socket on:@"disconnect" callback:^(NSArray * arrResponce, SocketAckEmitter * ackEmit) {
NSLog(@"kDisConnect called");
[[NSNotificationCenter defaultCenter] postNotificationName:kDisConnect object:arrResponce];
}];

[self.socket on:@"reconnect" callback:^(NSArray * arrResponce, SocketAckEmitter * ackEmit) {
NSLog(@"reconnect socket");

}];

//Socket reconnect_attempt
[self.socket on:@"reconnectAttempt" callback:^(NSArray * arrResponce, SocketAckEmitter * ackEmit) {
NSLog(@"reconnect_attempt socket");
 }];

@nuclearace please guide me!