Search in sources :

Example 1 with SessionEvent

use of org.thingsboard.server.extensions.api.plugins.ws.SessionEvent in project thingsboard by thingsboard.

the class DefaultWebsocketMsgHandler method handleWebSocketSessionEvent.

protected void handleWebSocketSessionEvent(PluginContext ctx, PluginWebsocketSessionRef sessionRef, SessionEventPluginWebSocketMsg wsMsg) {
    String sessionId = sessionRef.getSessionId();
    SessionEvent event = wsMsg.getPayload();
    log.debug(PROCESSING_MSG, sessionId, event);
    switch(event.getEventType()) {
        case ESTABLISHED:
            wsSessionsMap.put(sessionId, new WsSessionMetaData(sessionRef));
            break;
        case ERROR:
            log.debug("[{}] Unknown websocket session error: {}. ", sessionId, event.getError().orElse(null));
            break;
        case CLOSED:
            wsSessionsMap.remove(sessionId);
            cleanupWebSocketSession(ctx, sessionId);
            break;
    }
}
Also used : SessionEvent(org.thingsboard.server.extensions.api.plugins.ws.SessionEvent) WsSessionMetaData(org.thingsboard.server.extensions.api.plugins.ws.WsSessionMetaData)

Aggregations

SessionEvent (org.thingsboard.server.extensions.api.plugins.ws.SessionEvent)1 WsSessionMetaData (org.thingsboard.server.extensions.api.plugins.ws.WsSessionMetaData)1