Handle "bye" proxy messages.

This commit is contained in:
Joachim Bauch 2020-09-07 08:56:17 +02:00
parent b6a0597fb7
commit 73903315a9
Failed to extract signature
1 changed files with 13 additions and 0 deletions

View File

@ -661,6 +661,8 @@ func (c *mcuProxyConnection) processMessage(msg *ProxyServerMessage) {
c.processPayload(msg)
case "event":
c.processEvent(msg)
case "bye":
c.processBye(msg)
default:
log.Printf("Unsupported message received from %s: %+v", c.url, msg)
}
@ -734,6 +736,17 @@ func (c *mcuProxyConnection) processEvent(msg *ProxyServerMessage) {
log.Printf("Received event for unknown client %+v from %s", event, c.url)
}
func (c *mcuProxyConnection) processBye(msg *ProxyServerMessage) {
bye := msg.Bye
switch bye.Reason {
case "session_resumed":
log.Printf("Session %s on %s was resumed by other client, resetting", c.sessionId, c.url)
c.sessionId = ""
default:
log.Printf("Received bye with unsupported reason from %s %+v", c.url, bye)
}
}
func (c *mcuProxyConnection) sendHello() error {
c.helloMsgId = strconv.FormatInt(atomic.AddInt64(&c.msgId, 1), 10)
msg := &ProxyClientMessage{