Skip to content

Commit

Permalink
✨ feat: Enhance WebRTC setup for screen sharing capabilities
Browse files Browse the repository at this point in the history
This commit introduces improvements in the WebRTC configuration and session handling for robust screen sharing. Changes include the setup of new peer connections with updated SDP handling processes to enhance the performance and reliability of live screen sharing sessions. This update aims to provide smoother video transmission by refining the interceptor registration and session description handling mechanisms.

Related issue: YJU-OKURA#80
  • Loading branch information
yuminn-k committed Apr 24, 2024
1 parent 505b341 commit 36a3923
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ func handleConnections(w http.ResponseWriter, r *http.Request) {
return
}
defer conn.Close()
clients[conn] = true

clients[conn] = true // Register client

for {
var msg Message
Expand All @@ -377,7 +378,28 @@ func handleConnections(w http.ResponseWriter, r *http.Request) {
delete(clients, conn)
break
}
broadcast <- msg

// Handle different message types here
switch msg.Type {
case "offer", "answer", "candidate":
// Assume 'Data' contains the SDP or ICE candidate information
handleWebRTCMessage(msg, conn)
default:
broadcast <- msg // Continue handling other messages as before
}
}
}

func handleWebRTCMessage(msg Message, sender *websocket.Conn) {
// Broadcast WebRTC signaling messages to all clients except the sender
for client := range clients {
if client != sender {
if err := client.WriteJSON(msg); err != nil {
log.Printf("error sending to client: %v, error: %v", client.RemoteAddr(), err)
client.Close()
delete(clients, client)
}
}
}
}

Expand Down

0 comments on commit 36a3923

Please sign in to comment.