Skip to content

Instantly share code, notes, and snippets.

@AndrejGajdos
Created January 16, 2016 20:03
Show Gist options
  • Save AndrejGajdos/b781c4806884078574f2 to your computer and use it in GitHub Desktop.
Save AndrejGajdos/b781c4806884078574f2 to your computer and use it in GitHub Desktop.
MessageController class
package gwt.user.server;
import org.jboss.errai.bus.client.api.base.MessageBuilder;
import org.jboss.errai.bus.client.api.messaging.Message;
import org.jboss.errai.bus.client.api.messaging.MessageBus;
import org.jboss.errai.bus.client.api.messaging.MessageCallback;
import org.jboss.errai.bus.server.annotations.Service;
import org.jboss.errai.bus.server.service.ErraiService;
import org.jboss.errai.bus.server.service.ErraiServiceSingleton;
@Service
public class MessageController implements MessageCallback {
private MessageBus bus;
public MessageController() {
ErraiService<?> service = ErraiServiceSingleton.getService();
this.bus = service.getBus();
}
public void sendMessage() {
MessageBuilder.createMessage()
.toSubject("ClientService")
.signalling()
.with("text", "Hi There")
.noErrorHandling()
.sendNowWith(this.bus);
}
public void callback(Message message) {
System.out.println("MessageController received message");
this.sendMessage();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment