client and server establishing connections

This commit is contained in:
David Zhao
2020-11-06 23:57:03 -08:00
parent 218b9a0277
commit cba27d164b
8 changed files with 368 additions and 170 deletions
+12
View File
@@ -98,6 +98,18 @@ func (r *Room) Join(peerId string, sdp string) (peer *WebRTCPeer, err error) {
return
}
func (r *Room) RemovePeer(peerId string) {
r.lock.Lock()
defer r.lock.Unlock()
if p, ok := r.peers[peerId]; ok {
// also stop connection if needed
p.Close()
}
delete(r.peers, peerId)
}
// a peer in the room added a new track, subscribe other peers to it
func (r *Room) onTrackAdded(peer *WebRTCPeer, track *PeerTrack) {
r.lock.RLock()