Skip to content

Commit

Permalink
refactor: 优化设备上线离线消息时间戳逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Mar 12, 2024
1 parent 330930c commit 121c065
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ public DeviceMessageConnector(EventBus eventBus,
}
//从会话管理器里监听会话注销,转发为设备离线消息
if (event.getType() == DeviceSessionEvent.Type.unregister) {
return handleSessionMessage(new DeviceOfflineMessage(),event.getSession());
return handleSessionMessage(new DeviceOfflineMessage().timestamp(event.getTimestamp()),event.getSession());
}
//从会话管理器里监听会话注册,转发为设备上线消息
if (event.getType() == DeviceSessionEvent.Type.register) {
return handleSessionMessage(new DeviceOnlineMessage(),event.getSession());
return handleSessionMessage(new DeviceOnlineMessage().timestamp(event.getSession().connectTime()),event.getSession());
}
return Mono.empty();
});
Expand All @@ -172,7 +172,6 @@ private Mono<Void> handleSessionMessage(CommonDeviceMessage<?> message, DeviceSe
});

message.setDeviceId(session.getDeviceId());
message.setTimestamp(System.currentTimeMillis());

message.addHeader("connectTime", session.connectTime());
message.addHeader("from", "session");
Expand Down

0 comments on commit 121c065

Please sign in to comment.