mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
WebRTC events only for active peer connection.
This commit is contained in:
parent
2b693f4e52
commit
cd18a22655
@ -191,7 +191,11 @@ func (session *SessionCtx) SetWebRTCPeer(webrtcPeer types.WebRTCPeer) {
|
||||
session.webrtcPeer = webrtcPeer
|
||||
}
|
||||
|
||||
func (session *SessionCtx) SetWebRTCConnected(connected bool) {
|
||||
func (session *SessionCtx) SetWebRTCConnected(webrtcPeer types.WebRTCPeer, connected bool) {
|
||||
if webrtcPeer != session.webrtcPeer {
|
||||
return
|
||||
}
|
||||
|
||||
session.webrtcConnected = connected
|
||||
session.manager.emmiter.Emit("state_changed", session)
|
||||
|
||||
|
@ -56,7 +56,7 @@ type Session interface {
|
||||
|
||||
// webrtc
|
||||
SetWebRTCPeer(webrtcPeer WebRTCPeer)
|
||||
SetWebRTCConnected(connected bool)
|
||||
SetWebRTCConnected(webrtcPeer WebRTCPeer, connected bool)
|
||||
GetWebRTCPeer() WebRTCPeer
|
||||
}
|
||||
|
||||
|
@ -263,13 +263,13 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||
switch state {
|
||||
case webrtc.PeerConnectionStateConnected:
|
||||
session.SetWebRTCConnected(true)
|
||||
session.SetWebRTCConnected(peer, true)
|
||||
case webrtc.PeerConnectionStateDisconnected:
|
||||
fallthrough
|
||||
case webrtc.PeerConnectionStateFailed:
|
||||
connection.Close()
|
||||
case webrtc.PeerConnectionStateClosed:
|
||||
session.SetWebRTCConnected(false)
|
||||
session.SetWebRTCConnected(peer, false)
|
||||
videoStream.RemoveListener(&listener)
|
||||
|
||||
// should be stream stopped
|
||||
|
Loading…
Reference in New Issue
Block a user