2.1.7 限制自己使用命名空间
Server (app.js)
const io = require('socket.io')(80)
const chat = io
.of('/chat')
.on('connection',(socket)=>{
socket.emit('a message',{
that:'only',
'/chat':'will get'
})
chat.emit('a message',{
everyone:'in',
'/chat':'will get'
})
})
const news = io
.of('/news')
.on('connection',socket=>{
socket.emit('item',{news:'item'})
})Client (index.html)
Last updated
Was this helpful?