mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-06-07 21:04:42 +00:00
feat(telemost): Improve reconnection handling and message processing
This commit is contained in:
@@ -73,6 +73,12 @@ func Run(roomURL, keyHex string) error {
|
||||
|
||||
peer.SetReconnectCallback(func(dc *webrtc.DataChannel) {
|
||||
log.Println("Server reconnected - resetting multiplexer state")
|
||||
|
||||
for sid, conn := range s.connections {
|
||||
conn.Close()
|
||||
delete(s.connections, sid)
|
||||
}
|
||||
|
||||
s.mux.Reset()
|
||||
s.mux.UpdateSendFunc(func(frame []byte) error {
|
||||
encrypted, err := s.cipher.Encrypt(frame)
|
||||
@@ -158,15 +164,11 @@ func (s *Server) handleConnect(sid uint16, req ConnectRequest) {
|
||||
for {
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Printf("Read error sid=%d: %v", sid, err)
|
||||
}
|
||||
s.mux.CloseStream(sid)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.mux.SendData(sid, buf[:n]); err != nil {
|
||||
log.Printf("Send error sid=%d: %v", sid, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,14 @@ func (p *Peer) handleSignaling() {
|
||||
p.sendAck(uid)
|
||||
}
|
||||
|
||||
if _, ok := msg["updateDescription"]; ok {
|
||||
p.sendAck(uid)
|
||||
}
|
||||
|
||||
if _, ok := msg["vadActivity"]; ok {
|
||||
p.sendAck(uid)
|
||||
}
|
||||
|
||||
if offer, ok := msg["subscriberSdpOffer"].(map[string]interface{}); ok && !pubSent {
|
||||
sdp, _ := offer["sdp"].(string)
|
||||
pcSeq, _ := offer["pcSeq"].(float64)
|
||||
@@ -385,7 +393,7 @@ func (p *Peer) reconnect(ctx context.Context) error {
|
||||
p.pcPub.Close()
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
conn, err := GetConnectionInfo(p.roomURL, p.name)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user