2023-12-15 01:01:47 +08:00
|
|
|
package retransmiter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/iMDT/bbb-graphql-middleware/internal/common"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2024-07-06 00:35:08 +08:00
|
|
|
func RetransmitSubscriptionStartMessages(hc *common.HasuraConnection) {
|
2024-03-13 21:35:51 +08:00
|
|
|
log := log.WithField("_routine", "RetransmitSubscriptionStartMessages").WithField("browserConnectionId", hc.BrowserConn.Id).WithField("hasuraConnectionId", hc.Id)
|
2023-12-15 01:01:47 +08:00
|
|
|
|
2024-03-13 21:35:51 +08:00
|
|
|
hc.BrowserConn.ActiveSubscriptionsMutex.RLock()
|
|
|
|
for _, subscription := range hc.BrowserConn.ActiveSubscriptions {
|
2024-01-30 05:40:17 +08:00
|
|
|
|
|
|
|
//Not retransmitting Mutations
|
|
|
|
if subscription.Type == common.Mutation {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if subscription.LastSeenOnHasuraConnection != hc.Id {
|
2024-01-24 02:28:32 +08:00
|
|
|
|
2024-07-09 01:17:08 +08:00
|
|
|
log.Tracef("retransmiting subscription start: %v", string(subscription.Message))
|
2024-01-24 02:28:32 +08:00
|
|
|
|
|
|
|
if subscription.Type == common.Streaming && subscription.StreamCursorCurrValue != nil {
|
2024-07-06 00:35:08 +08:00
|
|
|
hc.BrowserConn.FromBrowserToHasuraChannel.Send(common.PatchQuerySettingLastCursorValue(subscription))
|
2024-01-24 02:28:32 +08:00
|
|
|
} else {
|
2024-07-06 00:35:08 +08:00
|
|
|
hc.BrowserConn.FromBrowserToHasuraChannel.Send(subscription.Message)
|
2024-01-24 02:28:32 +08:00
|
|
|
}
|
2023-12-15 01:01:47 +08:00
|
|
|
}
|
|
|
|
}
|
2024-03-13 21:35:51 +08:00
|
|
|
hc.BrowserConn.ActiveSubscriptionsMutex.RUnlock()
|
2023-12-15 01:01:47 +08:00
|
|
|
}
|