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
|
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.webrtcConnected = connected
|
||||||
session.manager.emmiter.Emit("state_changed", session)
|
session.manager.emmiter.Emit("state_changed", session)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ type Session interface {
|
|||||||
|
|
||||||
// webrtc
|
// webrtc
|
||||||
SetWebRTCPeer(webrtcPeer WebRTCPeer)
|
SetWebRTCPeer(webrtcPeer WebRTCPeer)
|
||||||
SetWebRTCConnected(connected bool)
|
SetWebRTCConnected(webrtcPeer WebRTCPeer, connected bool)
|
||||||
GetWebRTCPeer() WebRTCPeer
|
GetWebRTCPeer() WebRTCPeer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,13 +263,13 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
|||||||
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||||
switch state {
|
switch state {
|
||||||
case webrtc.PeerConnectionStateConnected:
|
case webrtc.PeerConnectionStateConnected:
|
||||||
session.SetWebRTCConnected(true)
|
session.SetWebRTCConnected(peer, true)
|
||||||
case webrtc.PeerConnectionStateDisconnected:
|
case webrtc.PeerConnectionStateDisconnected:
|
||||||
fallthrough
|
fallthrough
|
||||||
case webrtc.PeerConnectionStateFailed:
|
case webrtc.PeerConnectionStateFailed:
|
||||||
connection.Close()
|
connection.Close()
|
||||||
case webrtc.PeerConnectionStateClosed:
|
case webrtc.PeerConnectionStateClosed:
|
||||||
session.SetWebRTCConnected(false)
|
session.SetWebRTCConnected(peer, false)
|
||||||
videoStream.RemoveListener(&listener)
|
videoStream.RemoveListener(&listener)
|
||||||
|
|
||||||
// should be stream stopped
|
// should be stream stopped
|
||||||
|
Loading…
Reference in New Issue
Block a user