Sfoglia il codice sorgente

redis 拓展 websocket

luoyangwei 1 anno fa
parent
commit
f21db67795
1 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 8 2
      server/hub.go

+ 8 - 2
server/hub.go

@@ -117,9 +117,15 @@ func (h *Hub) remotelyEvent() {
 }
 
 func (h *Hub) OnPublishConnect(ctx context.Context, client *Client) error {
-	return h.rdb.Publish(ctx, connectChannelEvent, client.UserId).Err()
+	if !client.isRemotely {
+		return h.rdb.Publish(ctx, connectChannelEvent, client.UserId).Err()
+	}
+	return nil
 }
 
 func (h *Hub) OnPublishDisconnect(ctx context.Context, client *Client) error {
-	return h.rdb.Publish(ctx, disconnectChannelEvent, client.UserId).Err()
+	if !client.isRemotely {
+		return h.rdb.Publish(ctx, disconnectChannelEvent, client.UserId).Err()
+	}
+	return nil
 }