mirror of
https://github.com/screego/server.git
synced 2025-12-24 12:57:51 +08:00
In client.go
if room, ok := message.(outgoing.Room); ok {
c.info.RoomID = room.ID
}
this part isn't thread safe. It could happen that user disconnected but
wasn't removed from a room, because the disconnecting go routine
couldn't see the roomID yet.
34 lines
566 B
Go
34 lines
566 B
Go
package ws
|
|
|
|
func init() {
|
|
register("share", func() Event {
|
|
return &StartShare{}
|
|
})
|
|
}
|
|
|
|
type StartShare struct{}
|
|
|
|
func (e *StartShare) Execute(rooms *Rooms, current ClientInfo) error {
|
|
room, err := rooms.CurrentRoom(current)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
room.Users[current.ID].Streaming = true
|
|
|
|
v4, v6, err := rooms.config.TurnIPProvider.Get()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, user := range room.Users {
|
|
if current.ID == user.ID {
|
|
continue
|
|
}
|
|
room.newSession(current.ID, user.ID, rooms, v4, v6)
|
|
}
|
|
|
|
room.notifyInfoChanged()
|
|
return nil
|
|
}
|