Open Source Library Providing A Swift Based Socket.IO Client LIbrary

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:

var client = SocketIOClient(uri: uri, reconnect: true, timeout: 30)
client.open()

var socket = client.socket("namespace")
// Set a delegate on socket

And this example shows the delgate function for handling events:

@objc public protocol SocketIOSocketDelegate {
    // 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.

FacebookTwitterDiggStumbleUponGoogle Plus

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.

Leave a Reply

Your email address will not be published. Required fields are marked *