Browse Source

Include room session id in "joined" events.

This helps with matching signaling sessions with sessions in Talk.
pull/178/head
Joachim Bauch 1 month ago
parent
commit
76ad24ca62
No known key found for this signature in database GPG Key ID: 77C1D22D53E15F02
  1. 7
      api_signaling.go
  2. 8
      hub.go
  3. 3
      room.go
  4. 2
      room_test.go

7
api_signaling.go

@ -632,9 +632,10 @@ type EventServerMessage struct {
}
type EventServerMessageSessionEntry struct {
SessionId string `json:"sessionid"`
UserId string `json:"userid"`
User *json.RawMessage `json:"user,omitempty"`
SessionId string `json:"sessionid"`
UserId string `json:"userid"`
User *json.RawMessage `json:"user,omitempty"`
RoomSessionId string `json:"roomsessionid,omitempty"`
}
// MCU-related types

8
hub.go

@ -1186,11 +1186,15 @@ func (h *Hub) notifyUserJoinedRoom(room *Room, session *ClientSession, sessionDa
if sessions := room.AddSession(session, sessionData); len(sessions) > 0 {
events := make([]*EventServerMessageSessionEntry, 0, len(sessions))
for _, s := range sessions {
events = append(events, &EventServerMessageSessionEntry{
entry := &EventServerMessageSessionEntry{
SessionId: s.PublicId(),
UserId: s.UserId(),
User: s.UserData(),
})
}
if s, ok := s.(*ClientSession); ok {
entry.RoomSessionId = s.RoomSessionId()
}
events = append(events, entry)
}
msg := &ServerMessage{
Type: "event",

3
room.go

@ -439,6 +439,9 @@ func (r *Room) PublishSessionJoined(session Session, sessionData *RoomSessionDat
},
},
}
if session, ok := session.(*ClientSession); ok {
message.Event.Join[0].RoomSessionId = session.RoomSessionId()
}
if err := r.publish(message); err != nil {
log.Printf("Could not publish session joined message in room %s: %s", r.Id(), err)
}

2
room_test.go

@ -397,6 +397,8 @@ func TestRoom_RoomSessionData(t *testing.T) {
t.Error(err)
} else if err := client.checkMessageJoinedSession(message, hello.Hello.SessionId, expected); err != nil {
t.Error(err)
} else if message.Event.Join[0].RoomSessionId != roomId+"-"+hello.Hello.SessionId {
t.Errorf("Expected join room session id %s, got %+v", roomId+"-"+hello.Hello.SessionId, message.Event.Join[0])
}
session := hub.GetSessionByPublicId(hello.Hello.SessionId)

Loading…
Cancel
Save