From 3ed7ab3eeb53e8daf170f2e3293d5f5941aa9d91 Mon Sep 17 00:00:00 2001 From: Chyi-Kwei Yau Date: Thu, 12 May 2016 13:25:42 -0400 Subject: [PATCH 1/2] fix callback is not triggered on presence channels --- pubnub.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pubnub.py b/pubnub.py index 0fcd651b..c2796d8b 100755 --- a/pubnub.py +++ b/pubnub.py @@ -2264,11 +2264,7 @@ def sub_callback(response): except KeyError: chobj = self.subscriptions[ch[1]] - if ('-pnpres' in channel_list_2[ch[0]]): - cb = chobj['presence'] - else: - cb = chobj['callback'] - _invoke(cb, + _invoke(chobj['callback'], self.decrypt(response_list[ch[0]]), chobj['name'].split('-pnpres')[0], channel_list_2[ch[0]].split From 26aafa3eb5776e7cfcb2b8eac8cf09b46c40b1ee Mon Sep 17 00:00:00 2001 From: Chyi-Kwei Yau Date: Thu, 26 May 2016 16:57:36 -0400 Subject: [PATCH 2/2] add channel_group parameter to here_now function --- pubnub.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pubnub.py b/pubnub.py index c2796d8b..d88a4723 100755 --- a/pubnub.py +++ b/pubnub.py @@ -1023,7 +1023,7 @@ def where_now(self, uuid=None, callback=None, error=None): callback=self._return_wrapped_callback(callback), error=self._return_wrapped_callback(error)) - def here_now(self, channel, uuids=True, state=False, + def here_now(self, channel=None, channel_group=None, uuids=True, state=False, callback=None, error=None): """Get here now data. @@ -1036,8 +1036,14 @@ def here_now(self, channel, uuids=True, state=False, Args: channel: (string) (optional) Specifies the channel name to return occupancy - results. If channel is not provided, here_now will - return data for all channels. + results. If channel and channel group are not + provided, here_now will return data for all + channels. If both channel and channel group are + provided, the function will return error. + + channel_group: (string) (optional) + Specifies the channel group name to return + occupancy results. callback: (optional) A callback method should be passed to the method. @@ -1089,6 +1095,11 @@ def here_now(self, channel, uuids=True, state=False, data = {'auth': self.auth_key, 'pnsdk': self.pnsdk} + if channel_group is not None and len(channel_group) > 0: + urlcomponents.append('channel') + urlcomponents.append(',') + data['channel-group'] = channel_group + if state is True: data['state'] = '1'