Search in sources :

Example 1 with SessionType

use of org.thingsboard.server.common.msg.session.SessionType in project thingsboard by thingsboard.

the class DeviceActorMessageProcessor method processSubscriptionCommands.

private void processSubscriptionCommands(ActorContext context, ToDeviceActorMsg msg) {
    SessionId sessionId = msg.getSessionId();
    SessionType sessionType = msg.getSessionType();
    FromDeviceMsg inMsg = msg.getPayload();
    if (inMsg.getMsgType() == MsgType.SUBSCRIBE_ATTRIBUTES_REQUEST) {
        logger.debug("[{}] Registering attributes subscription for session [{}]", deviceId, sessionId);
        attributeSubscriptions.put(sessionId, new SessionInfo(sessionType, msg.getServerAddress()));
    } else if (inMsg.getMsgType() == MsgType.UNSUBSCRIBE_ATTRIBUTES_REQUEST) {
        logger.debug("[{}] Canceling attributes subscription for session [{}]", deviceId, sessionId);
        attributeSubscriptions.remove(sessionId);
    } else if (inMsg.getMsgType() == MsgType.SUBSCRIBE_RPC_COMMANDS_REQUEST) {
        logger.debug("[{}] Registering rpc subscription for session [{}][{}]", deviceId, sessionId, sessionType);
        rpcSubscriptions.put(sessionId, new SessionInfo(sessionType, msg.getServerAddress()));
        sendPendingRequests(context, sessionId, sessionType, msg.getServerAddress());
    } else if (inMsg.getMsgType() == MsgType.UNSUBSCRIBE_RPC_COMMANDS_REQUEST) {
        logger.debug("[{}] Canceling rpc subscription for session [{}][{}]", deviceId, sessionId, sessionType);
        rpcSubscriptions.remove(sessionId);
    }
}
Also used : FromDeviceMsg(org.thingsboard.server.common.msg.session.FromDeviceMsg) SessionType(org.thingsboard.server.common.msg.session.SessionType) SessionId(org.thingsboard.server.common.data.id.SessionId)

Aggregations

SessionId (org.thingsboard.server.common.data.id.SessionId)1 FromDeviceMsg (org.thingsboard.server.common.msg.session.FromDeviceMsg)1 SessionType (org.thingsboard.server.common.msg.session.SessionType)1