classWebSocket{
constructor(){
this.joined=0
}
init(server){
constio=socketIO(server)
io.on('connection',socket=>{
socket.on('disconnect',()=>console.log('userleave'))
socket.on('userJoin',(data)=>{
if(this.joined<=2)socket.broadcast.emit('userJoin',data)
this.joined++
})
socket.on('answer',(data)=>socket.broadcast.emit('answer',data))
socket.on('answerIce',(data)=>socket.broadcast.emit('answerIce',data))
socket.on('answerOffer',(data)=>socket.broadcast.emit('answerOffer',data))
socket.on('answerAnswer',(data)=>socket.broadcast.emit('answerAnswer',data))
socket.on('iceSwop',(data)=>socket.broadcast.emit('iceSwop',data))
})
}
}
基于�socket.io�实现 SDP数据推送