Created
January 16, 2016 20:03
-
-
Save AndrejGajdos/b781c4806884078574f2 to your computer and use it in GitHub Desktop.
MessageController class
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.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