Skip to content

Instantly share code, notes, and snippets.

@spericas
Created June 22, 2020 15:05
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 spericas/2568da181dcdce3b52547260683aaddc to your computer and use it in GitHub Desktop.
Save spericas/2568da181dcdce3b52547260683aaddc to your computer and use it in GitHub Desktop.
@ServerEndpoint(
value = "/websocket",
encoders = { UppercaseEncoder.class })
public class MessageBoardEndpoint {
@Inject
private MessageQueue messageQueue;
@OnMessage
public void onMessage(Session session, String message) {
if (message.equals("SEND")) {
while (!messageQueue.isEmpty()) {
session.getBasicRemote()
.sendObject(messageQueue.pop());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment