Last active
May 17, 2016 11:35
-
-
Save jarbaspsf/2d78738b90bf3a40d7432c2d01d802fa to your computer and use it in GitHub Desktop.
Criando web-sockets no rantera (Grails)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Eventos recebendo objeto | |
var gSonServerEvent0 = function() { | |
websocketClient.subscribe("/topic/atividades", function(message) { | |
var run = function(data) { | |
return gs.mc($("#teste"),"append",[gs.plus((gs.plus("<p>", data)), "</p>")]); | |
}; | |
run(gs.toGroovy(jQuery.parseJSON(message.body), null)); | |
}); | |
}; | |
//Eventos recebendo uma lista | |
var gSonServerEvent0 = function() { | |
websocketClient.subscribe("/topic/teste", function(message) { | |
var run = function(data) { | |
return gs.mc(data,"each",[function(book) { | |
return gs.mc($("#teste"),"append",[gs.plus((gs.plus((gs.plus("Titulo: ", gs.gp(book,"title"))), " Autor: ")), gs.gp(book,"autor"))]); | |
}]); | |
}; | |
run(gs.toGroovy(jQuery.parseJSON(message.body), null)); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment