Showing posts with label websocket. Show all posts
Showing posts with label websocket. Show all posts

Friday, June 5, 2015

[Swift] ActionHero Client with Swift

Tadaa
Tadaaaaa 

Here's Swift version


client = AHClient()

client.on("alert") { message in println(message)}
client.on("api") { message in println(message)}

client.on("welcome") { message in self.appendMessage(message)}
client.on("say") { message in self.appendMessage(message)}

client.connect() {
    self.client.roomAdd("defaultRoom");
}

Compare to JS version

client = new ActionheroClient;

client.on('alert',        function(message){ alert( JSON.stringify(message) ) })
client.on('api',          function(message){ alert( JSON.stringify(message) ) })

client.on('welcome',      function(message){ appendMessage(message); })
client.on('say',          function(message){ appendMessage(message); })
client.connect(function(err, details){
    if(err != null){
        console.log(err);
    }else{
        client.roomAdd("defaultRoom");
        document.getElementById("name").innerHTML = "\"color:#" + intToARGB(hashCode(client.id)) + "\">" + client.id + "" 
    }
});

Nice eh? :D

BTW : It's just proof of concept, no error/test, so heavy fork is need!
FYI : I'm moving on to MQTT , so don't expect any update so soon.
TL;DR : https://github.com/katopz/actionhero-client-swift

Happy Coding!

Thursday, May 28, 2015

[Swift] Hello World Primus with Swift via ActionHeroJS

Pretty much same as Objective-C implement nothing to special, just this fancy block...
class Block<T>  {
    let f : T
    init (_ f: T){ self.f = f }
    var casted: AnyObject { get { return unsafeBitCast(f, AnyObject.self) } }
}
Which I can't find shorter way yet


Happy Coding!



Wednesday, May 27, 2015

Sunday, October 19, 2014

Monday, August 11, 2014

[PaaS] Free Platform as a Service for NodeJS+Websockets


I did wrote about Backend as a service (BaaS) for free (development/trial out) here. This time I will collect about free Platform-as-a-Service (PaaS) that can handle NodeJS and Websockets for later use.

Why now? Because... Gordon  has working example which use  NodeJS and Websockets working quite well and seem to be cross-platform (if I read it right) so let collect resources and do labs yeah!

Info

Detail

  • 512MB RAM
  • 1x CPU Share
  • $0.05/dyno-hour
  • Databases 10K rows