Skip to content

Commit

Permalink
Add log messages for device agent connect/disconnect events
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jul 20, 2023
1 parent dd2952b commit bece171
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions forge/ee/lib/deviceEditor/DeviceTunnelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class DeviceTunnelManager {
wsSocket.close()
delete tunnel.forwardedWS[id]
}
this.app.log.info(`Device ${deviceId} tunnel closed. id:${tunnel.id}`)
})

/** @type {httpHandler} */
Expand Down Expand Up @@ -257,6 +258,8 @@ class DeviceTunnelManager {
const wsToDevice = connection.socket
tunnel.forwardedWS[requestId] = wsToDevice

this.app.log.info(`Device ${deviceId} tunnel id:${tunnel.id} - new editor connection req:${requestId} `)

wsToDevice.on('message', msg => {
// Forward messages sent by the editor down to the device
// console.log(`[${tunnel.id}] [${requestId}] E>R`, msg.toString())
Expand All @@ -267,6 +270,7 @@ class DeviceTunnelManager {
}))
})
wsToDevice.on('close', msg => {
this.app.log.info(`Device ${deviceId} tunnel id:${tunnel.id} - editor connection closed req:${requestId} `)
// The editor has closed its websocket. Send notification to the
// device so it can close its corresponing connection
// console.log(`[${tunnel.id}] [${requestId}] E>R closed`)
Expand All @@ -281,6 +285,7 @@ class DeviceTunnelManager {
}
})
}
this.app.log.info(`Device ${deviceId} tunnel connected. id:${tunnel.id}`)
return true
}

Expand Down

0 comments on commit bece171

Please sign in to comment.