Created
June 27, 2012 05:00
-
-
Save darylteo/3001599 to your computer and use it in GitHub Desktop.
EventBus message body type
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
load('vertx.js'); | |
var eb = vertx.eventBus; | |
vertx.setPeriodic(1000,function(id){ | |
eb.send( | |
'server.address', | |
'a String', | |
function(reply){ | |
console.log(reply); | |
} | |
); | |
); |
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
import org.vertx.java.core.*; | |
import org.vertx.java.core.eventbus.*; | |
import org.vertx.java.core.json.*; | |
import org.vertx.java.deploy.*; | |
public class server extends Verticle { | |
public void start(){ | |
EventBus eb = vertx.eventBus(); | |
eb.registerHandler( | |
"server.address", | |
new Handler<Message<JsonObject>>(){ | |
public void handle(Message<JsonObject> message){ | |
System.out.println(message.body); | |
JsonObject body = message.body; | |
System.out.println(body.getString("")); | |
JsonObject object = | |
new JsonObject("{ \"reply\":\"message\" }"); | |
message.reply(object); | |
} | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment