mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-01-02 17:17:03 +08:00
test
This commit is contained in:
parent
a9ab9baa23
commit
97636c4c7a
@ -66,16 +66,13 @@ func TestRecvOnline(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
pubsub := ts.rdb.Subscribe(ctx, cachekey.OnlineChannel)
|
pubsub := ts.rdb.Subscribe(ctx, cachekey.OnlineChannel)
|
||||||
|
|
||||||
// 等待订阅确认
|
|
||||||
_, err := pubsub.Receive(ctx)
|
_, err := pubsub.Receive(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not subscribe: %v", err)
|
log.Fatalf("Could not subscribe: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建一个通道来接收消息
|
|
||||||
ch := pubsub.Channel()
|
ch := pubsub.Channel()
|
||||||
|
|
||||||
// 处理接收到的消息
|
|
||||||
for msg := range ch {
|
for msg := range ch {
|
||||||
fmt.Printf("Received message from channel %s: %s\n", msg.Channel, msg.Payload)
|
fmt.Printf("Received message from channel %s: %s\n", msg.Channel, msg.Payload)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user