Last active
January 16, 2016 19:30
-
-
Save AndrejGajdos/9c778800d311c8fd1e66 to your computer and use it in GitHub Desktop.
MessageController receives message from client and send back a 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
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