增加移动端推送title content
This commit is contained in:
@@ -33,6 +33,18 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushMobileMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String title, String content, String data) {
|
||||
WebSocketMessageDto dto = new WebSocketMessageDto();
|
||||
dto.setSessionKeys(sessionKey);
|
||||
dto.setMessage(createMsg(webSocketMsgType, title, content, data));
|
||||
try {
|
||||
WebSocketUtils.publishMessage(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("发送分布式消息失败,error:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishAll(WebSocketMsgType webSocketMsgType, String data) {
|
||||
try {
|
||||
@@ -60,4 +72,13 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
|
||||
return msg.toJSONString();
|
||||
}
|
||||
|
||||
private String createMsg(WebSocketMsgType webSocketMsgType, String title, String content, Object data) {
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("type", webSocketMsgType.getCode());
|
||||
msg.put("title", title);
|
||||
msg.put("content", content);
|
||||
msg.put("data", data);
|
||||
return msg.toJSONString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user