js套件地址 https://github.com/muaz-khan/RTCMultiConnection
server套件地址 https://github.com/muaz-khan/RTCMultiConnection-Server
要解决的就是server代码的跨域问题
原装写法:
解决写法:
javascript
// 喜欢组合语法的自己组
const io = new ioServer.Server(httpApp, {
cors: {
origin: "*"
}
});
io.on('connection', function(socket) {
RTCMultiConnectionServer.addSocket(socket, config);
// ----------------------
// below code is optional
const params = socket.handshake.query;
if (!params.socketCustomEvent) {
params.socketCustomEvent = 'custom-message';
}
socket.on(params.socketCustomEvent, function(message) {
socket.broadcast.emit(params.socketCustomEvent, message);
});
});
ok齐活搞定不谢