鍍金池/ 問答/HTML/ wx.connectSocket 傳參在nodedjs端如何接收?

wx.connectSocket 傳參在nodedjs端如何接收?

wx.connectSocket({
      url: 'wss://example.qq.com',
      data:{
        x: '',
        y: ''
      },
      header:{ 
        'content-type': 'application/json'
      },
      protocols: ['protocol1'],
      method:"GET"
    })

參數(shù)data在nodedjs端如何接收?
服務(wù)端用的是ws,在request里沒有找到data

回答
編輯回答
奧特蛋
const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
  });

  ws.send('something');
});

message接收

2018年1月12日 03:47