refactor fix

main v1.2.3
Ayush Mukherjee 4 years ago
parent eaea84fde0
commit e67493c13d

@ -45,12 +45,14 @@ server.on('upgrade', (req, socket, head) => {
if (pathname[1] === 'ws' && get(token)) { if (pathname[1] === 'ws' && get(token)) {
wss1.handleUpgrade(req, socket, head, (socket) => { wss1.handleUpgrade(req, socket, head, (socket) => {
req.id = token req.id = token
wss1.emit('connection', socket, req); wss1.emit('connection', socket, req)
}) })
} else if (pathname[1] === 'stream') { } else if (pathname[1] === 'stream') {
wss2.handleUpgrade(req, socket, head, (socket) => { wss2.handleUpgrade(req, socket, head, (socket) => {
if (req.id != null || req.id != '') {
req.id = token req.id = token
wss2.emit('connection', socket, req); wss2.emit('connection', socket, req)
}
}) })
} }
}) })

@ -37,13 +37,11 @@ const recvUpdate = async (channel, data) => {
const sendInitial = async (id) => { const sendInitial = async (id) => {
const c = connections[id] const c = connections[id]
if (c.streamid !== null) {
const stream = await crud['streams'].getById(c.streamid) const stream = await crud['streams'].getById(c.streamid)
c.connection.send(JSON.stringify({ c.connection.send(JSON.stringify({
event: 'streams:read', event: 'streams:read',
data: stream, data: stream,
})) }))
}
} }
module.exports = { module.exports = {

Loading…
Cancel
Save