mirror of https://github.com/jetkvm/kvm.git
add more log
This commit is contained in:
parent
3bc74b1ce5
commit
b1baaa5bd5
14
webrtc.go
14
webrtc.go
|
@ -111,9 +111,10 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
session.rpcQueue = make(chan webrtc.DataChannelMessage, 256)
|
session.rpcQueue = make(chan webrtc.DataChannelMessage, 256)
|
||||||
go func() {
|
go func() {
|
||||||
for msg := range session.rpcQueue {
|
for msg := range session.rpcQueue {
|
||||||
|
scopedLogger.Trace().Interface("msg", msg).Msg("Processing RPC message")
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
onRPCMessage(msg, session)
|
onRPCMessage(msg, session)
|
||||||
scopedLogger.Info().Dur("duration", time.Since(start)).Interface("msg", msg).Msg("RPC message processed")
|
scopedLogger.Trace().Dur("duration", time.Since(start)).Interface("msg", msg).Msg("RPC message processed")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -123,8 +124,15 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
case "rpc":
|
case "rpc":
|
||||||
session.RPCChannel = d
|
session.RPCChannel = d
|
||||||
d.OnMessage(func(msg webrtc.DataChannelMessage) {
|
d.OnMessage(func(msg webrtc.DataChannelMessage) {
|
||||||
|
l := scopedLogger.With().Interface("msg", msg).Logger()
|
||||||
|
// just in case the channel is closed, we don't want to panic
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
l.Warn().Interface("reason", r).Msg("RPC channel is closed, no need to enqueue message")
|
||||||
|
}
|
||||||
|
}()
|
||||||
// Enqueue to ensure ordered processing
|
// Enqueue to ensure ordered processing
|
||||||
scopedLogger.Info().Interface("msg", msg).Msg("Enqueuing RPC message")
|
l.Trace().Msg("Enqueuing RPC message")
|
||||||
session.rpcQueue <- msg
|
session.rpcQueue <- msg
|
||||||
})
|
})
|
||||||
triggerOTAStateUpdate()
|
triggerOTAStateUpdate()
|
||||||
|
@ -191,11 +199,13 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//state changes on closing browser tab disconnected->failed, we need to manually close it
|
//state changes on closing browser tab disconnected->failed, we need to manually close it
|
||||||
if connectionState == webrtc.ICEConnectionStateFailed {
|
if connectionState == webrtc.ICEConnectionStateFailed {
|
||||||
scopedLogger.Debug().Msg("ICE Connection State is failed, closing peerConnection")
|
scopedLogger.Debug().Msg("ICE Connection State is failed, closing peerConnection")
|
||||||
_ = peerConnection.Close()
|
_ = peerConnection.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if connectionState == webrtc.ICEConnectionStateClosed {
|
if connectionState == webrtc.ICEConnectionStateClosed {
|
||||||
scopedLogger.Debug().Msg("ICE Connection State is closed, unmounting virtual media")
|
scopedLogger.Debug().Msg("ICE Connection State is closed, unmounting virtual media")
|
||||||
if session == currentSession {
|
if session == currentSession {
|
||||||
|
|
Loading…
Reference in New Issue