一对一聊天开发完成

This commit is contained in:
2024-10-31 17:24:37 +08:00
parent 8662ce971d
commit 1c152e2d1a
5 changed files with 103 additions and 19 deletions

View File

@@ -69,9 +69,12 @@ public class WebSocketServer {
*/
@OnMessage
public void onMessage(String message) throws IOException {
System.out.println("-------------------------------------------------------------------");
JSONObject jsonObject = JSONObject.parseObject(message);
String userId = jsonObject.getString("userId");
String type = jsonObject.getString("type");
System.out.println(type);
System.out.println(message);
if (type.equals(MessageType.CHAT.getType())) {
log.debug("聊天消息推送");
sendToUser(userId, JSONObject.toJSONString(jsonObject));