bigbluebutton-Github/bbb-graphql-middleware/internal/hasura/retransmiter/retransmiter.go

42 lines
1.4 KiB
Go
Raw Normal View History

package retransmiter
import (
2024-08-09 03:50:41 +08:00
"bbb-graphql-middleware/internal/common"
)
func RetransmitSubscriptionStartMessages(hc *common.HasuraConnection) {
2024-03-13 21:35:51 +08:00
hc.BrowserConn.ActiveSubscriptionsMutex.RLock()
defer hc.BrowserConn.ActiveSubscriptionsMutex.RUnlock()
2024-08-29 03:34:28 +08:00
userCurrentlyInMeeting := false
if hasuraRole, exists := hc.BrowserConn.BBBWebSessionVariables["x-hasura-role"]; exists {
2024-08-29 03:34:28 +08:00
userCurrentlyInMeeting = hasuraRole == "bbb_client"
}
for _, subscription := range hc.BrowserConn.ActiveSubscriptions {
//Not retransmitting Mutations
if subscription.Type == common.Mutation {
continue
}
//When user left the meeting, Retransmit only Presence Manager subscriptions
2024-08-29 03:34:28 +08:00
if !userCurrentlyInMeeting &&
subscription.OperationName != "getUserInfo" &&
subscription.OperationName != "getUserCurrent" {
hc.BrowserConn.Logger.Debugf("Skipping retransmit %s because the user is offline", subscription.OperationName)
continue
}
if subscription.LastSeenOnHasuraConnection != hc.Id {
hc.BrowserConn.Logger.Tracef("retransmiting subscription start: %v", string(subscription.Message))
if subscription.Type == common.Streaming && subscription.StreamCursorCurrValue != nil {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(common.PatchQuerySettingLastCursorValue(subscription))
} else {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(subscription.Message)
}
}
}
}