use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.
the class DeviceActorMessageProcessor method processUplinkNotificationMsg.
private void processUplinkNotificationMsg(TbActorCtx context, SessionInfoProto sessionInfo, TransportProtos.UplinkNotificationMsg uplinkNotificationMsg) {
String nodeId = sessionInfo.getNodeId();
sessions.entrySet().stream().filter(kv -> kv.getValue().getSessionInfo().getNodeId().equals(nodeId) && (kv.getValue().isSubscribedToAttributes() || kv.getValue().isSubscribedToRPC())).forEach(kv -> {
ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(kv.getKey().getMostSignificantBits()).setSessionIdLSB(kv.getKey().getLeastSignificantBits()).setUplinkNotificationMsg(uplinkNotificationMsg).build();
systemContext.getTbCoreToTransportService().process(kv.getValue().getSessionInfo().getNodeId(), msg);
});
}
use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.
the class DeviceActorMessageProcessor method notifyTransportAboutDeviceCredentialsUpdate.
void notifyTransportAboutDeviceCredentialsUpdate(UUID sessionId, SessionInfoMetaData sessionMd, DeviceCredentials deviceCredentials) {
ToTransportUpdateCredentialsProto.Builder notification = ToTransportUpdateCredentialsProto.newBuilder();
notification.addCredentialsId(deviceCredentials.getCredentialsId());
notification.addCredentialsValue(deviceCredentials.getCredentialsValue());
ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setToTransportUpdateCredentialsNotification(notification).build();
systemContext.getTbCoreToTransportService().process(sessionMd.getSessionInfo().getNodeId(), msg);
}
use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.
the class DeviceActorMessageProcessor method sendToTransport.
private void sendToTransport(GetAttributeResponseMsg responseMsg, SessionInfoProto sessionInfo) {
ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionInfo.getSessionIdMSB()).setSessionIdLSB(sessionInfo.getSessionIdLSB()).setGetAttributesResponse(responseMsg).build();
systemContext.getTbCoreToTransportService().process(sessionInfo.getNodeId(), msg);
}
use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.
the class DeviceActorMessageProcessor method notifyTransportAboutClosedSession.
private void notifyTransportAboutClosedSession(UUID sessionId, SessionInfoMetaData sessionMd, String message) {
SessionCloseNotificationProto sessionCloseNotificationProto = SessionCloseNotificationProto.newBuilder().setMessage(message).build();
ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setSessionCloseNotification(sessionCloseNotificationProto).build();
systemContext.getTbCoreToTransportService().process(sessionMd.getSessionInfo().getNodeId(), msg);
}
use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.
the class DefaultTbClusterService method broadcastEntityChangeToTransport.
public <T> void broadcastEntityChangeToTransport(TenantId tenantId, EntityId entityid, T entity, TbQueueCallback callback) {
String entityName = (entity instanceof HasName) ? ((HasName) entity).getName() : entity.getClass().getName();
log.trace("[{}][{}][{}] Processing [{}] change event", tenantId, entityid.getEntityType(), entityid.getId(), entityName);
TransportProtos.EntityUpdateMsg entityUpdateMsg = TransportProtos.EntityUpdateMsg.newBuilder().setEntityType(entityid.getEntityType().name()).setData(ByteString.copyFrom(encodingService.encode(entity))).build();
ToTransportMsg transportMsg = ToTransportMsg.newBuilder().setEntityUpdateMsg(entityUpdateMsg).build();
broadcast(transportMsg, callback);
}
Aggregations