Swift with Socket.IO w00t

swift and socket io

I wanted to create a auctions app, and for that i need realtime data from a socket io server. So i was googling, and yes there was a socket io lib for swift and java (android), and thats really nice.

https://github.com/socketio/socket.io-client-swift

So i included the socket io client in a podfile and linked the library in swift. Finally i configure socket io in my viewDidLoad func.

  let socket = SocketIOClient(socketURL: NSURL(string: Config.socketIOUrl)!, options: [.Log(false), .ForcePolling(true), .Secure(true)])

And i did this in my business logic:

 self.socket.on("bid_message_\(veiling_id)") { data2,ack2 in
            print(veiling_id)
        }

And it was working like a charm.

How nice is that 🙂

Very soon i will start the same app for Android, lets see how that works out 🙂

Deel dit artikel met je vriendenShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someonePin on Pinterest

Leave a Reply