mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
lint fix minor problems.
This commit is contained in:
parent
e45bd7098f
commit
d5c0c62675
@ -118,8 +118,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
audioTrack.AddToConnection(connection)
|
||||
if err != nil {
|
||||
if err := audioTrack.AddToConnection(connection); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -130,8 +129,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
videoTrack.AddToConnection(connection)
|
||||
if err != nil {
|
||||
if err := videoTrack.AddToConnection(connection); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -157,6 +155,20 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
iceTrickle: manager.config.ICETrickle,
|
||||
}
|
||||
|
||||
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||
switch state {
|
||||
case webrtc.PeerConnectionStateConnected:
|
||||
session.SetWebRTCConnected(peer, true)
|
||||
case webrtc.PeerConnectionStateDisconnected,
|
||||
webrtc.PeerConnectionStateFailed:
|
||||
connection.Close()
|
||||
case webrtc.PeerConnectionStateClosed:
|
||||
session.SetWebRTCConnected(peer, false)
|
||||
videoTrack.RemoveStream()
|
||||
audioTrack.RemoveStream()
|
||||
}
|
||||
})
|
||||
|
||||
cursorImage := func(entry *cursor.ImageEntry) {
|
||||
if err := peer.SendCursorImage(entry.Cursor, entry.Image); err != nil {
|
||||
logger.Err(err).Msg("could not send cursor image")
|
||||
@ -173,20 +185,6 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
}
|
||||
}
|
||||
|
||||
connection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||
switch state {
|
||||
case webrtc.PeerConnectionStateConnected:
|
||||
session.SetWebRTCConnected(peer, true)
|
||||
case webrtc.PeerConnectionStateDisconnected,
|
||||
webrtc.PeerConnectionStateFailed:
|
||||
connection.Close()
|
||||
case webrtc.PeerConnectionStateClosed:
|
||||
session.SetWebRTCConnected(peer, false)
|
||||
videoTrack.RemoveStream()
|
||||
audioTrack.RemoveStream()
|
||||
}
|
||||
})
|
||||
|
||||
dataChannel.OnOpen(func() {
|
||||
manager.curImage.AddListener(&cursorImage)
|
||||
manager.curPosition.AddListener(&cursorPosition)
|
||||
@ -214,7 +212,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
return
|
||||
}
|
||||
|
||||
if err = manager.handle(message.Data, session); err != nil {
|
||||
if err := manager.handle(message.Data, session); err != nil {
|
||||
logger.Err(err).Msg("data handle failed")
|
||||
}
|
||||
})
|
||||
|
@ -69,7 +69,7 @@ func (peer *PeerStreamTrack) RemoveStream() {
|
||||
defer peer.streamMu.Unlock()
|
||||
|
||||
if peer.stream != nil {
|
||||
peer.stream.RemoveListener(&peer.listener)
|
||||
_ = peer.stream.RemoveListener(&peer.listener)
|
||||
peer.stream = nil
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user