Server error handling
This commit is contained in:
parent
aa325dad50
commit
841d03cdec
46
server.js
46
server.js
|
@ -220,26 +220,34 @@ ptserver_io.on('connection', (socket) => {
|
||||||
socket.disconnect(disconnect)
|
socket.disconnect(disconnect)
|
||||||
}
|
}
|
||||||
function updateUserData (username, userData, room) {
|
function updateUserData (username, userData, room) {
|
||||||
for (var i in ptserver_io.sockets.adapter.rooms[room].users) {
|
if (!room === undefined || room === undefined || room === null) {
|
||||||
var user = ptserver_io.sockets.adapter.rooms[room].users[i]
|
console.log('Tried to update a user who isnt in a room', username, userData, room)
|
||||||
if (user.username === username) {
|
return false
|
||||||
// This is our user
|
}
|
||||||
user.time = userData.time
|
try {
|
||||||
user.maxTime = userData.maxTime
|
for (var i in ptserver_io.sockets.adapter.rooms[room].users) {
|
||||||
user.title = userData.title
|
var user = ptserver_io.sockets.adapter.rooms[room].users[i]
|
||||||
user.lastHeartbeat = (new Date()).getTime()
|
if (user.username === username) {
|
||||||
user.playerState = userData.playerState
|
// This is our user
|
||||||
user.rawTitle = userData.rawTitle
|
user.time = userData.time
|
||||||
user.clientResponseTime = userData.clientResponseTime
|
user.maxTime = userData.maxTime
|
||||||
user.type = userData.type
|
user.title = userData.title
|
||||||
user.showName = userData.showName || ''
|
user.lastHeartbeat = (new Date()).getTime()
|
||||||
user.playerProduct = userData.playerProduct || ''
|
user.playerState = userData.playerState
|
||||||
user.status = userData.status || 'unknown'
|
user.rawTitle = userData.rawTitle
|
||||||
user.machineIdentifier = userData.machineIdentifier || ''
|
user.clientResponseTime = userData.clientResponseTime
|
||||||
user.key = userData.key
|
user.type = userData.type
|
||||||
user.uuid = userData.uuid
|
user.showName = userData.showName || ''
|
||||||
return
|
user.playerProduct = userData.playerProduct || ''
|
||||||
|
user.status = userData.status || 'unknown'
|
||||||
|
user.machineIdentifier = userData.machineIdentifier || ''
|
||||||
|
user.key = userData.key
|
||||||
|
user.uuid = userData.uuid
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Failed to update a user', username, userData, room)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function transferHost (user, newHostPredicate) {
|
function transferHost (user, newHostPredicate) {
|
||||||
|
|
Loading…
Reference in New Issue