Procházet zdrojové kódy

redis 拓展 websocket

luoyangwei před 1 rokem
rodič
revize
f21db67795
1 změnil soubory, kde provedl 8 přidání a 2 odebrání
  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
 }