Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created February 14, 2017 03:39
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 abhirockzz/d7daf85ba1a746e3001f2dc381a0975b to your computer and use it in GitHub Desktop.
Save abhirockzz/d7daf85ba1a746e3001f2dc381a0975b to your computer and use it in GitHub Desktop.
Stateful EJB In WebSocket (1/2)
@Stateful
public class ClientChatState {
//...who needs details !
}
@ServerEndpoint("/letschat/{login-id}")
public class ChatEndpoint {
@EJB
private ClientChatState ccs; //stateful EJB
private String userID;
@OnOpen
public void connOpened(@PathParam("login-id") String loginID, Session session) {
ccs.setUser(loginID)
.currentState(State.JOINED); //everyone likes a fluent API!
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment