瀏覽代碼

redis 拓展 websocket

luoyangwei 1 年之前
父節點
當前提交
f21db67795
共有 1 個文件被更改,包括 8 次插入2 次删除
  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
 }