400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

原生nodejs使用websocket

  1. 安装:
    npm  install  ws
  2. 服务端(nodejs):
    var WebSocketServer = require('ws').Server,
    wss = new WebSocketServer({ port: 8080 });
    wss.on('connection', function (ws) {
    console.log('client connected');
    ws.on('message', function (message) {
        console.log(message);
    });
    });
  3. 客户端:
  4. 测试:
    原生nodejs使用websocket
    原生nodejs使用websocket

标题名称:原生nodejs使用websocket
本文网址:http://mbwzsj.com/article/jdijgj.html

其他资讯

让你的专属顾问为你服务