mirror of
https://github.com/AlexandreRouma/wiscast.git
synced 2026-04-18 23:52:42 +00:00
progress
This commit is contained in:
20
user.go
20
user.go
@@ -10,6 +10,7 @@ import "github.com/gorilla/websocket"
|
||||
type User struct {
|
||||
// WebSocket used to communicate with the user
|
||||
sock *websocket.Conn;
|
||||
sockSendMtx sync.Mutex;
|
||||
|
||||
// Display mutex
|
||||
displayMtx sync.Mutex;
|
||||
@@ -18,6 +19,23 @@ type User struct {
|
||||
display *Display;
|
||||
}
|
||||
|
||||
// Send an ICE candiate to the user
|
||||
func (this *User) iceCandidate(candidate string) {
|
||||
// Acquire the sending mutex
|
||||
this.sockSendMtx.Lock()
|
||||
|
||||
// Send the candidate
|
||||
sendMessage(this.sock, Message{
|
||||
mtype: "ice-candidate",
|
||||
arguments: map[string]interface{}{
|
||||
"candidate": candidate,
|
||||
},
|
||||
})
|
||||
|
||||
// Release the sending mutex
|
||||
this.sockSendMtx.Unlock()
|
||||
}
|
||||
|
||||
// Connection handler for users
|
||||
func userHandler(sock *websocket.Conn) {
|
||||
// Initialize the user instance
|
||||
@@ -170,8 +188,6 @@ func userHandler(sock *websocket.Conn) {
|
||||
// Send the ice candidtate to the display
|
||||
user.display.iceCandidate(candidate);
|
||||
|
||||
// TODO: Check error
|
||||
|
||||
// Release the user's display pointer
|
||||
user.displayMtx.Unlock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user