Socket.IO enables easy real-time two-way web communication and previously I mentioned the Objective-C Socket.IO client library SocketIO-Objc.
More recently I’ve also mentioned the Swift based websockets library Starscream and the Swift based HTTP networking library AlamoFire.
Here’s an open source project submitted by Shuo Li providing a Swift based Socket.IO client library that utilizes the Starscream and AlamoFire libraries called SocketIOCocoa.
This source code example from the readme shows how to create a client, and socket:
client.open()
var socket = client.socket("namespace")
// Set a delegate on socket
And this example shows the delgate function for handling events:
// Called when the socket received a low level packet
optional func socketOnPacket(socket: SocketIOSocket, packet: SocketIOPacket)
<pre><code>// Called when the socket received an event
func socketOnEvent(socket: SocketIOSocket, event: String, data: AnyObject?)
// Called when the socket is open
func socketOnOpen(socket: SocketIOSocket)
// Called when the socket is on error
func socketOnError(socket: SocketIOSocket, error: String, description: String?)
</code></pre>
}
You can find SocketIOCocoa on Github here.
A nice Socket.IO client library created in Swift.
- An Open Source Swift Based Websockets Client Library
- An iOS Objective-C Socket.IO Client Library For Easy Real-Time Web Communication
- Example: A Swift Language Based Hacker News Reading App
- Tutorial: Building A Simple iOS TCP Socket Based App Client And Server
- Open Source Swift Library Making It Easier To Use SQLite Databases
Original article: Open Source Library Providing A Swift Based Socket.IO Client LIbrary
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.




