mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-08 08:36:32 +02:00
Merge pull request #228 from strukturag/send-to-session
Send directly to local session with disconnected client.
This commit is contained in:
commit
ef8d5ff628
29
hub.go
29
hub.go
|
@ -1253,7 +1253,7 @@ func (h *Hub) processMessageMsg(client *Client, message *ClientMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var recipient *Client
|
var recipient *ClientSession
|
||||||
var subject string
|
var subject string
|
||||||
var clientData *MessageClientMessageData
|
var clientData *MessageClientMessageData
|
||||||
var serverRecipient *MessageClientMessageRecipient
|
var serverRecipient *MessageClientMessageRecipient
|
||||||
|
@ -1299,15 +1299,18 @@ func (h *Hub) processMessageMsg(client *Client, message *ClientMessage) {
|
||||||
|
|
||||||
subject = "session." + msg.Recipient.SessionId
|
subject = "session." + msg.Recipient.SessionId
|
||||||
h.mu.RLock()
|
h.mu.RLock()
|
||||||
recipient = h.clients[data.Sid]
|
sess, found := h.sessions[data.Sid]
|
||||||
if recipient == nil {
|
if found {
|
||||||
|
if sess, ok := sess.(*ClientSession); ok {
|
||||||
|
recipient = sess
|
||||||
|
}
|
||||||
|
|
||||||
// Send to client connection for virtual sessions.
|
// Send to client connection for virtual sessions.
|
||||||
sess := h.sessions[data.Sid]
|
if sess.ClientType() == HelloClientTypeVirtual {
|
||||||
if sess != nil && sess.ClientType() == HelloClientTypeVirtual {
|
|
||||||
virtualSession := sess.(*VirtualSession)
|
virtualSession := sess.(*VirtualSession)
|
||||||
clientSession := virtualSession.Session()
|
clientSession := virtualSession.Session()
|
||||||
subject = "session." + clientSession.PublicId()
|
subject = "session." + clientSession.PublicId()
|
||||||
recipient = clientSession.GetClient()
|
recipient = clientSession
|
||||||
// The client should see his session id as recipient.
|
// The client should see his session id as recipient.
|
||||||
serverRecipient = &MessageClientMessageRecipient{
|
serverRecipient = &MessageClientMessageRecipient{
|
||||||
Type: "session",
|
Type: "session",
|
||||||
|
@ -1391,15 +1394,11 @@ func (h *Hub) processMessageMsg(client *Client, message *ClientMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if recipientSession := recipient.GetSession(); recipientSession != nil {
|
msg.Recipient.SessionId = session.PublicId()
|
||||||
msg.Recipient.SessionId = session.PublicId()
|
// It may take some time for the publisher (which is the current
|
||||||
// It may take some time for the publisher (which is the current
|
// client) to start his stream, so we must not block the active
|
||||||
// client) to start his stream, so we must not block the active
|
// goroutine.
|
||||||
// goroutine.
|
go h.processMcuMessage(session, recipient, message, msg, clientData)
|
||||||
go h.processMcuMessage(session, recipientSession, message, msg, clientData)
|
|
||||||
} else { // nolint
|
|
||||||
// Client is not connected yet.
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
recipient.SendMessage(response)
|
recipient.SendMessage(response)
|
||||||
|
|
Loading…
Reference in a new issue