docs/faq.html
This library is NOT a WebSockets library. This library is only for servers that implement the socket.io protocol, such as socket.io. If you need a plain WebSockets client check out Starscream for Swift and JetFire for Objective-C.
One of the most common reasons your event might not be called is if the client is released by ARC.
Take this code for example:
class Manager {
func addHandlers() {
let manager = SocketManager(socketURL: URL(string: "http://somesocketioserver.com")!)
manager.defaultSocket.on("myEvent") {data, ack in
print(data)
}
}
}
This code is incorrect , and the event handler will never be called. Because as soon as this method is called manager will be released, along with the socket, and its memory reclaimed.
A correct way would be:
class Manager {
let manager = SocketManager(socketURL: URL(string: "http://somesocketioserver.com")!)
func addHandlers() {
manager.defaultSocket.on("myEvent") {data, ack in
print(data)
}
}
}