洪城义警-正式版后台
zengh
2022-03-29 3d4d308b589080f6cb58271230ba796c67f58494
任务增加类型
3 files modified
3 ■■■■■ changed files
src/main/java/org/springblade/modules/webscoket/WebSocketHandler.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/webscoket/index.html 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/webscoket/service/impl/PushMsgServiceImpl.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/webscoket/WebSocketHandler.java
@@ -104,6 +104,7 @@
                //登录链接
                String id = jsonObj.get("id").toString();
                NettyConfig.getUserChannelMap().put(id,ctx.channel());
                NettyConfig.getChannelGroup().add(ctx.channel());
                System.out.println("___________________"+jsonObj.get("type"));
                System.out.println(jsonObj.get("id")+ "____________________________用户连接成功");
src/main/java/org/springblade/modules/webscoket/index.html
@@ -11,6 +11,7 @@
        if(window.WebSocket){
            socket = new WebSocket("ws://localhost:9034/websocket");
            socket.onmessage = function(event){
                debugger
                var ta = document.getElementById('responseContent');
                ta.value += event.data + "\r\n";
            };
src/main/java/org/springblade/modules/webscoket/service/impl/PushMsgServiceImpl.java
@@ -29,6 +29,7 @@
        String name = group.name();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("xqid", msg);
        jsonObject.put("type", "taks");
        System.out.println("空间大小:" + group.size() + ",名字:" + name);
        group.writeAndFlush(new TextWebSocketFrame(String.valueOf(jsonObject)));
    }