Refresh presence on websocket pong
This commit is contained in:
+15
-10
@@ -519,16 +519,7 @@ func (s *Session) dispatchRaw(raw []byte) {
|
||||
func (s *Session) dispatch(msg *ClientComMessage) {
|
||||
now := types.TimeNow()
|
||||
atomic.StoreInt64(&s.lastAction, now.UnixNano())
|
||||
if !s.uid.IsZero() && s.tenantID.IsValid() {
|
||||
if err := store.RefreshUserPresence(s.tenantID, s.uid, s.sid, currentNodeID()); err != nil {
|
||||
logs.Warn.Println("s.dispatch: failed to refresh user presence", s.uid, err, s.sid)
|
||||
}
|
||||
for _, topic := range s.groupSubs() {
|
||||
if err := store.MarkTopicMemberOnline(s.tenantID, topic, s.uid, currentNodeID()); err != nil {
|
||||
logs.Warn.Println("s.dispatch: failed to refresh group member presence", topic, s.uid, err, s.sid)
|
||||
}
|
||||
}
|
||||
}
|
||||
s.refreshPresence("s.dispatch")
|
||||
|
||||
// This should be the first block here, before any other checks.
|
||||
var resp *ServerComMessage
|
||||
@@ -701,6 +692,20 @@ func (s *Session) dispatch(msg *ClientComMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) refreshPresence(context string) {
|
||||
if s.uid.IsZero() || !s.tenantID.IsValid() {
|
||||
return
|
||||
}
|
||||
if err := store.RefreshUserPresence(s.tenantID, s.uid, s.sid, currentNodeID()); err != nil {
|
||||
logs.Warn.Println(context+": failed to refresh user presence", s.uid, err, s.sid)
|
||||
}
|
||||
for _, topic := range s.groupSubs() {
|
||||
if err := store.MarkTopicMemberOnline(s.tenantID, topic, s.uid, currentNodeID()); err != nil {
|
||||
logs.Warn.Println(context+": failed to refresh group member presence", topic, s.uid, err, s.sid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Request to subscribe to a topic.
|
||||
func (s *Session) subscribe(msg *ClientComMessage) {
|
||||
if strings.HasPrefix(msg.Original, "new") || strings.HasPrefix(msg.Original, "nch") {
|
||||
|
||||
Reference in New Issue
Block a user