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

32 lines
1.1 KiB
Go
Raw Normal View History

package retransmiter
import (
"github.com/iMDT/bbb-graphql-middleware/internal/common"
log "github.com/sirupsen/logrus"
)
func RetransmitSubscriptionStartMessages(hc *common.HasuraConnection, fromBrowserToHasuraChannel *common.SafeChannelByte) {
2024-03-13 21:35:51 +08:00
log := log.WithField("_routine", "RetransmitSubscriptionStartMessages").WithField("browserConnectionId", hc.BrowserConn.Id).WithField("hasuraConnectionId", hc.Id)
2024-03-13 21:35:51 +08:00
hc.BrowserConn.ActiveSubscriptionsMutex.RLock()
for _, subscription := range hc.BrowserConn.ActiveSubscriptions {
//Not retransmitting Mutations
if subscription.Type == common.Mutation {
continue
}
if subscription.LastSeenOnHasuraConnection != hc.Id {
log.Tracef("retransmiting subscription start: %v", subscription.Message)
if subscription.Type == common.Streaming && subscription.StreamCursorCurrValue != nil {
fromBrowserToHasuraChannel.Send(common.PatchQuerySettingLastCursorValue(subscription))
} else {
fromBrowserToHasuraChannel.Send(subscription.Message)
}
}
}
2024-03-13 21:35:51 +08:00
hc.BrowserConn.ActiveSubscriptionsMutex.RUnlock()
}