Skip to content

codenergic/eventbus-java-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

EventBus Java Client

This is a port of vertx3-eventbus-client.js writen in Java.

How to

Create EventBus instance

EventBus eventBus = EventBusAdapter.connect("ws://localhost/eventbus/websocket");

Register onOpen and onClose Events

eventBus.onOpen(new ConnectionHandler() {
	@Override
	public void handle() {
		// handle on connection open
	}
});

eventBus.onClose(new ConnectionHandler() {
	@Override
	public void handle() {
		// handle on connection closed
	}
});

Open Connection

eventBus.open();

Registering Handlers

eventBus.registerHandler("chat.message.123", new MessageHandler() {
	@Override
	public void handle(Message message) {
		System.out.println("I have received a message: " + message.body());
	}
});

Publishing Messages

eventBus.publish("chat.message", "Hello");

Sending Messages

eventBus.send("chat.token", null, null, new ReplyHandler() {
	@Override
	public void handle(Message message) {
		System.out.println("Received reply: " + message.body());
	}
});

About

A port of vertx3-eventbus-client.js written in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages