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!
No comments:
Post a Comment