0

在 pubnub 群聊中很容易,但我找不到正确的 1 对 1 聊天方式,我关注了http://pubnub.github.io/pubnub-design-patterns/2015/03/05/Inbound-Channel-Pattern。 .html _ 所以结论是每个用户都订阅了唯一的频道,不是吗?

 PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@“mypublishkey” subscribeKey:@“mysubskey”];
  configuration.uuid=@“myuuid”;//unique id help to find presence
 configuration.presenceHeartbeatValue = 120;
//unsubscribe from channel until no response in 120 sec

  configuration.presenceHeartbeatInterval = 30;//send to server each 30 second
      self.client = [PubNub clientWithConfiguration:configuration];
      [self.client addListener:self];
_delegateconfig=delegate;

    // Subscribe to demo channel with presence observation
    [self.client subscribeToChannels: @[channelname] withPresence:YES];

/ --用于列出所有用户或频道--- /

我在这里调用了NowWithCompletion,它显示了所有正常的频道列表

例如https://www.pubnub.com/docs/cocoa-objective-c/presence

/ --------取消订阅频道-------- /

[self.client unsubscribeFromChannels:@[channelname] withPresence:YES]; 不工作,因为当我在这里调用NowWithCompletion 时显示之前的所有列表,但在 120 秒后没问题,但我想要即时再膨胀。

4

1 回答 1

2

这是与 pubnub 一对一聊天的完美概念 http://pubnub.github.io/pubnub-design-patterns/2015/03/05/Inbound-Channel-Pattern.html

于 2017-04-21T11:20:15.290 回答