1
zj
2024-07-12 c2cf572d823f5ab410fd82ae169f012caf3386c7
websocketSerivce/src/main/java/org/example/websocket/server/WsServer.java
@@ -68,10 +68,10 @@
    }
    public void sendMessageToAll(String message) {
        Map<String, Object> map = jsonToMap(message);
        if (map.get("pid").equals("00000001")) {
            System.out.println(message);
        }
//        Map<String, Object> map = jsonToMap(message);
//        if (map.get("pid").equals("00000001")) {
//            System.out.println(message);
//        }
        try {
            List<Future<?>> futures = new ArrayList<>();
            wsServers.forEach(ws -> {
@@ -109,11 +109,11 @@
        }
    }
    public static Map<String, Object> jsonToMap(String json) {
        Gson gson = new Gson();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        return gson.fromJson(json, type);
    }
//
//    public static Map<String, Object> jsonToMap(String json) {
//        Gson gson = new Gson();
//        Type type = new TypeToken<Map<String, Object>>() {
//        }.getType();
//        return gson.fromJson(json, type);
//    }
}