Websocket
Ajax 喝水要拿起水杯,喝完要再放下
Websocket 用吸管喝水,要喝時或喝太多要退回去杯子都不必再次拿起水杯ws
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 3002 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});其他相關框架
engine.io
socket.io
再複習一次,首先必須先再連線範圍作用域才可做事
最基本兩種
再來是房間部分
簡單範例
Socket.io 模組之安全機制
ws 模組之安全機制驗證
注意事項
ngrok
Last updated