Commit 622300181f03ff3457b58a28445ed318b769c0f9
1 parent
50bfe1ff
Notification for DeviceStateService about created Device
Showing
4 changed files
with
21 additions
and
2 deletions
... | ... | @@ -32,6 +32,7 @@ import org.thingsboard.server.actors.rpc.RpcManagerActor; |
32 | 32 | import org.thingsboard.server.actors.rpc.RpcSessionCreateRequestMsg; |
33 | 33 | import org.thingsboard.server.actors.session.SessionManagerActor; |
34 | 34 | import org.thingsboard.server.actors.stats.StatsActor; |
35 | +import org.thingsboard.server.common.data.Device; | |
35 | 36 | import org.thingsboard.server.common.data.id.DeviceId; |
36 | 37 | import org.thingsboard.server.common.data.id.EntityId; |
37 | 38 | import org.thingsboard.server.common.data.id.TenantId; |
... | ... | @@ -48,6 +49,7 @@ import org.thingsboard.server.gen.cluster.ClusterAPIProtos; |
48 | 49 | import org.thingsboard.server.service.cluster.discovery.DiscoveryService; |
49 | 50 | import org.thingsboard.server.service.cluster.discovery.ServerInstance; |
50 | 51 | import org.thingsboard.server.service.cluster.rpc.ClusterRpcService; |
52 | +import org.thingsboard.server.service.state.DeviceStateService; | |
51 | 53 | import scala.concurrent.Await; |
52 | 54 | import scala.concurrent.Future; |
53 | 55 | import scala.concurrent.duration.Duration; |
... | ... | @@ -81,6 +83,9 @@ public class DefaultActorService implements ActorService { |
81 | 83 | @Autowired |
82 | 84 | private DiscoveryService discoveryService; |
83 | 85 | |
86 | + @Autowired | |
87 | + private DeviceStateService deviceStateService; | |
88 | + | |
84 | 89 | private ActorSystem system; |
85 | 90 | |
86 | 91 | private ActorRef appActor; |
... | ... | @@ -199,7 +204,7 @@ public class DefaultActorService implements ActorService { |
199 | 204 | public void onReceivedMsg(ServerAddress source, ClusterAPIProtos.ClusterMessage msg) { |
200 | 205 | ServerAddress serverAddress = new ServerAddress(source.getHost(), source.getPort()); |
201 | 206 | log.info("Received msg [{}] from [{}]", msg.getMessageType().name(), serverAddress); |
202 | - if(log.isDebugEnabled()){ | |
207 | + if (log.isDebugEnabled()) { | |
203 | 208 | log.info("MSG: ", msg); |
204 | 209 | } |
205 | 210 | switch (msg.getMessageType()) { |
... | ... | @@ -254,4 +259,8 @@ public class DefaultActorService implements ActorService { |
254 | 259 | rpcManagerActor.tell(msg, ActorRef.noSender()); |
255 | 260 | } |
256 | 261 | |
262 | + @Override | |
263 | + public void onDeviceAdded(Device device) { | |
264 | + deviceStateService.onDeviceAdded(device); | |
265 | + } | |
257 | 266 | } | ... | ... |
... | ... | @@ -15,11 +15,13 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.transport; |
17 | 17 | |
18 | -import org.thingsboard.server.common.data.security.DeviceCredentialsFilter; | |
18 | +import org.thingsboard.server.common.data.Device; | |
19 | 19 | import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
20 | 20 | |
21 | 21 | public interface SessionMsgProcessor { |
22 | 22 | |
23 | 23 | void process(SessionAwareMsg msg); |
24 | 24 | |
25 | + void onDeviceAdded(Device device); | |
26 | + | |
25 | 27 | } | ... | ... |
... | ... | @@ -92,6 +92,7 @@ public class GatewaySessionCtx { |
92 | 92 | device.setType(deviceType); |
93 | 93 | device = deviceService.saveDevice(device); |
94 | 94 | relationService.saveRelationAsync(new EntityRelation(gateway.getId(), device.getId(), "Created")); |
95 | + processor.onDeviceAdded(device); | |
95 | 96 | } |
96 | 97 | GatewayDeviceSessionCtx ctx = new GatewayDeviceSessionCtx(this, device); |
97 | 98 | devices.put(deviceName, ctx); | ... | ... |