Skip to content

Instantly share code, notes, and snippets.

@AndrejGajdos
Last active January 16, 2016 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrejGajdos/9c778800d311c8fd1e66 to your computer and use it in GitHub Desktop.
Save AndrejGajdos/9c778800d311c8fd1e66 to your computer and use it in GitHub Desktop.
MessageController receives message from client and send back a reply
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.MessageCallback;
import org.jboss.errai.bus.client.api.messaging.RequestDispatcher;
import org.jboss.errai.bus.server.annotations.Service;
import com.google.inject.Inject;
@Service
public class MessageController implements MessageCallback {
// https://docs.jboss.org/author/display/ERRAI/Dependency+Injection
@Inject
private RequestDispatcher dispatcher;
public MessageController() {}
public void sendMessage() {
MessageBuilder.createMessage()
.toSubject("ClientService")
.signalling()
.with("text", "Hi There")
.noErrorHandling()
.sendNowWith(this.dispatcher);
}
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