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