mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-23 16:02:12 +02:00
Send initial user flags to internal sessions asynchronously.
This commit is contained in:
parent
532587eb9f
commit
706a876fc3
|
@ -45,6 +45,7 @@ type AsyncRoomMessage struct {
|
|||
Type string `json:"type"`
|
||||
|
||||
SessionId string `json:"sessionid,omitempty"`
|
||||
ClientType string `json:"clienttype,omitempty"`
|
||||
}
|
||||
|
||||
type SendOfferMessage struct {
|
||||
|
|
12
room.go
12
room.go
|
@ -247,6 +247,9 @@ func (r *Room) processBackendRoomRequestAsyncRoom(message *AsyncRoomMessage) {
|
|||
switch message.Type {
|
||||
case "sessionjoined":
|
||||
r.notifySessionJoined(message.SessionId)
|
||||
if message.ClientType == HelloClientTypeInternal {
|
||||
r.publishUsersChangedWithInternal()
|
||||
}
|
||||
default:
|
||||
log.Printf("Unsupported async room request with type %s in %s: %+v", message.Type, r.Id(), message)
|
||||
}
|
||||
|
@ -307,6 +310,7 @@ func (r *Room) AddSession(session Session, sessionData *json.RawMessage) {
|
|||
AsyncRoom: &AsyncRoomMessage{
|
||||
Type: "sessionjoined",
|
||||
SessionId: sid,
|
||||
ClientType: session.ClientType(),
|
||||
},
|
||||
}); err != nil {
|
||||
log.Printf("Error publishing joined event for session %s: %s", sid, err)
|
||||
|
@ -530,10 +534,6 @@ func (r *Room) PublishSessionJoined(session Session, sessionData *RoomSessionDat
|
|||
if err := r.publish(message); err != nil {
|
||||
log.Printf("Could not publish session joined message in room %s: %s", r.Id(), err)
|
||||
}
|
||||
|
||||
if session.ClientType() == HelloClientTypeInternal {
|
||||
r.publishUsersChangedWithInternal()
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Room) PublishSessionLeft(session Session) {
|
||||
|
@ -840,6 +840,10 @@ func (r *Room) NotifySessionChanged(session Session) {
|
|||
|
||||
func (r *Room) publishUsersChangedWithInternal() {
|
||||
message := r.getParticipantsUpdateMessage(r.users)
|
||||
if len(message.Event.Update.Users) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.publish(message); err != nil {
|
||||
log.Printf("Could not publish users changed message in room %s: %s", r.Id(), err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue