From a74f424a8678f4619eb834fc420537f4e46af514 Mon Sep 17 00:00:00 2001 From: Joachim Bauch <bauch@struktur.de> Date: Thu, 2 Jun 2016 10:55:50 +0200 Subject: [PATCH] Also send "Conference" message after "Room" messages. --- go/channelling/api/api.go | 2 ++ go/channelling/api/handle_hello.go | 19 ++----------------- go/channelling/api/handle_room.go | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/go/channelling/api/api.go b/go/channelling/api/api.go index b70df1f4..ed020385 100644 --- a/go/channelling/api/api.go +++ b/go/channelling/api/api.go @@ -199,5 +199,7 @@ func (api *channellingAPI) OnIncomingProcessed(sender channelling.Sender, sessio switch msg.Type { case "Hello": api.HelloProcessed(sender, session, msg, reply, err) + case "Room": + api.RoomProcessed(sender, session, msg, reply, err) } } diff --git a/go/channelling/api/handle_hello.go b/go/channelling/api/handle_hello.go index 81360af0..f329acac 100644 --- a/go/channelling/api/handle_hello.go +++ b/go/channelling/api/handle_hello.go @@ -48,22 +48,7 @@ func (api *channellingAPI) HandleHello(session *channelling.Session, hello *chan } func (api *channellingAPI) HelloProcessed(sender channelling.Sender, session *channelling.Session, msg *channelling.DataIncoming, reply interface{}, err error) { - if err != nil { - return - } - - // If user joined a server-managed conference room, send list of session ids to all participants. - if room, ok := api.RoomStatusManager.Get(session.Roomid); ok && room.GetType() == "Conference" { - if sessionids := room.SessionIDs(); len(sessionids) > 1 { - cid := session.Roomid - session.Broadcaster.Broadcast("", session.Roomid, &channelling.DataOutgoing{ - To: cid, - Data: &channelling.DataConference{ - Type: "Conference", - Id: cid, - Conference: sessionids, - }, - }) - } + if err == nil { + api.SendConferenceRoomUpdate(session) } } diff --git a/go/channelling/api/handle_room.go b/go/channelling/api/handle_room.go index e09ec70b..62409a6f 100644 --- a/go/channelling/api/handle_room.go +++ b/go/channelling/api/handle_room.go @@ -33,3 +33,26 @@ func (api *channellingAPI) HandleRoom(session *channelling.Session, room *channe return room, err } + +func (api *channellingAPI) RoomProcessed(sender channelling.Sender, session *channelling.Session, msg *channelling.DataIncoming, reply interface{}, err error) { + if err == nil { + api.SendConferenceRoomUpdate(session) + } +} + +func (api *channellingAPI) SendConferenceRoomUpdate(session *channelling.Session) { + // If user joined a server-managed conference room, send list of session ids to all participants. + if room, ok := api.RoomStatusManager.Get(session.Roomid); ok && room.GetType() == "Conference" { + if sessionids := room.SessionIDs(); len(sessionids) > 1 { + cid := session.Roomid + session.Broadcaster.Broadcast("", session.Roomid, &channelling.DataOutgoing{ + To: cid, + Data: &channelling.DataConference{ + Type: "Conference", + Id: cid, + Conference: sessionids, + }, + }) + } + } +}