diff --git a/code/VideoAccess-VCMP/api/app/lib/service/socket.js b/code/VideoAccess-VCMP/api/app/lib/service/socket.js index 28957f3..e15f6ef 100644 --- a/code/VideoAccess-VCMP/api/app/lib/service/socket.js +++ b/code/VideoAccess-VCMP/api/app/lib/service/socket.js @@ -2,25 +2,24 @@ module.exports = async function factory (app, opts) { - app.socket.on('connection', async (socket) => { - console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已连接'); + app.socket.on('connection', async (socket) => { + console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已连接:' + socket.id); + socket.on('disconnecting', async (reason) => { + console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已断开连接:' + reason); + }) + }) - socket.on('disconnecting', async (reason) => { - console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已断开连接:' + reason); - }) - }) + // 使用测试 保持链接 + // setInterval(async () => { + // // const { connected } = app.socket.sockets + // // const roomId = 'ROOM_' + Math.random() + // // if (connected) { + // // for (let c in connected) { + // // connected[c].join(roomId) + // // } + // // app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, }) + // // } - // 使用测试 - // setInterval(async () => { - // const { connected } = app.socket.sockets - // const roomId = 'ROOM_' + Math.random() - // if (connected) { - // for (let c in connected) { - // connected[c].join(roomId) - // } - // app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, }) - // } - - // app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', }) - // }, 1000) + // app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', }) + // }, 1000) }