mirror of
https://github.com/AlexandreRouma/wiscast.git
synced 2026-04-20 08:22:42 +00:00
bugfix
This commit is contained in:
18
user.go
18
user.go
@@ -53,6 +53,9 @@ func userHandler(sock *websocket.Conn) {
|
||||
// Initialize the user instance
|
||||
user := User{ sock: sock, display: nil };
|
||||
|
||||
// Acquire the sending mutex
|
||||
user.sockSendMtx.Lock()
|
||||
|
||||
// Send back the config for the user to use
|
||||
sendMessage(sock, Message{
|
||||
mtype: "config",
|
||||
@@ -64,6 +67,9 @@ func userHandler(sock *websocket.Conn) {
|
||||
},
|
||||
});
|
||||
|
||||
// Release the sending mutex
|
||||
user.sockSendMtx.Unlock()
|
||||
|
||||
// Message loop
|
||||
for {
|
||||
// Receive a message
|
||||
@@ -136,11 +142,17 @@ func userHandler(sock *websocket.Conn) {
|
||||
// Log the connection
|
||||
log.Println("User successfully connected to display: ID='" + dispID + "'");
|
||||
|
||||
// Acquire the sending mutex
|
||||
user.sockSendMtx.Lock()
|
||||
|
||||
// Notify the user of the successful connection
|
||||
sendMessage(sock, Message{
|
||||
mtype: "success",
|
||||
});
|
||||
|
||||
// Release the sending mutex
|
||||
user.sockSendMtx.Unlock()
|
||||
|
||||
case "webrtc-offer":
|
||||
// Check that the message contains an offer
|
||||
offer := msg.arguments["offer"];
|
||||
@@ -173,6 +185,9 @@ func userHandler(sock *websocket.Conn) {
|
||||
// Release the user's display pointer
|
||||
user.displayMtx.Unlock();
|
||||
|
||||
// Acquire the sending mutex
|
||||
user.sockSendMtx.Lock()
|
||||
|
||||
// Send back the response
|
||||
sendMessage(sock, Message{
|
||||
mtype: "webrtc-answer",
|
||||
@@ -181,6 +196,9 @@ func userHandler(sock *websocket.Conn) {
|
||||
},
|
||||
});
|
||||
|
||||
// Release the sending mutex
|
||||
user.sockSendMtx.Unlock()
|
||||
|
||||
case "ice-candidate":
|
||||
// Check that the message contains an ice candidate
|
||||
candidate := msg.arguments["candidate"]
|
||||
|
||||
Reference in New Issue
Block a user