use of com.baeldung.model.Message in project tutorials by eugenp.
the class ChatEndpoint method onClose.
@OnClose
public void onClose(Session session) throws IOException, EncodeException {
chatEndpoints.remove(this);
Message message = new Message();
message.setFrom(users.get(session.getId()));
message.setContent("Disconnected!");
broadcast(message);
}
use of com.baeldung.model.Message in project tutorials by eugenp.
the class ChatEndpoint method onOpen.
@OnOpen
public void onOpen(Session session, @PathParam("username") String username) throws IOException, EncodeException {
this.session = session;
chatEndpoints.add(this);
users.put(session.getId(), username);
Message message = new Message();
message.setFrom(username);
message.setContent("Connected!");
broadcast(message);
}