Search in sources :

Example 1 with OnClose

use of javax.websocket.OnClose 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);
}
Also used : Message(com.baeldung.model.Message) OnMessage(javax.websocket.OnMessage) OnClose(javax.websocket.OnClose)

Example 2 with OnClose

use of javax.websocket.OnClose in project zeppelin by apache.

the class NotebookServer method onClose.

@OnClose
public void onClose(Session session, CloseReason closeReason) throws IOException {
    NotebookSocket notebookSocket = sessionIdNotebookSocketMap.get(session.getId());
    if (null == notebookSocket) {
        session.close();
    } else {
        int code = closeReason.getCloseCode().getCode();
        String reason = closeReason.getReasonPhrase();
        onClose(notebookSocket, code, reason);
    }
}
Also used : ServerEndpoint(javax.websocket.server.ServerEndpoint) OnClose(javax.websocket.OnClose)

Example 3 with OnClose

use of javax.websocket.OnClose in project muikku by otavanopisto.

the class CoOpsDocumentWebSocket method onClose.

@OnClose
public void onClose(final Session session, CloseReason closeReason, @PathParam("HTMLMATERIALID") String fileId, @PathParam("SESSIONID") String sessionId) {
    synchronized (this) {
        fileClients.get(fileId).remove(session.getId());
        CoOpsSession coOpsSession = coOpsSessionController.findSessionBySessionId(sessionId);
        if (coOpsSession != null) {
            closeSession(coOpsSession);
        }
    }
}
Also used : CoOpsSession(fi.otavanopisto.muikku.plugins.material.coops.model.CoOpsSession) OnClose(javax.websocket.OnClose)

Aggregations

OnClose (javax.websocket.OnClose)3 Message (com.baeldung.model.Message)1 CoOpsSession (fi.otavanopisto.muikku.plugins.material.coops.model.CoOpsSession)1 OnMessage (javax.websocket.OnMessage)1 ServerEndpoint (javax.websocket.server.ServerEndpoint)1