Esempio n. 1
0
 def _on_fbns_register(self, payload):
     # Sucsessuf registered in FBNS and we got notification token for Instagram API registration
     if payload.get('error', None):
         error = payload['error']
         raise Exception('FBNS Register error message: {error}'.format(**logger))
     token = payload.get('token')
     logger.debug('[REG_RESP_TOPIC] {token}'.format(**locals()))
     self.on_fbns_token(token)
Esempio n. 2
0
 def _on_fbns_connack(self, flags, returncode, data):
     if returncode != 0:
         desc = FBNSConnAckReturnCodes.get(returncode, 'Unknown')
         raise Exception('Connack returncode: {returncode} - {desc}'.format(**locals()))
     data = data.decode('utf8')
     logger.debug('[FBNS CONNACK] {data}'.format(**locals()))
     data = json.loads(data)
     self.on_fbns_auth(data)
     self._register()
Esempio n. 3
0
 def on_message(self, _, topic, payload, qos, properties):
     payload = zlib.decompress(payload)
     payload = json.loads(payload)
     if topic == self.MESSAGE_TOPIC_ID:
         push = FBNSPush(payload)
         self._on_fbns_message(push)
     elif topic == self.REG_RESP_TOPIC_ID:
         self._on_fbns_register(payload)
     else:
         logger.debug('[UNKNOWN MESSAGE] {topic}, {payload}'.format(**locals()))
Esempio n. 4
0
    def __init__(self, data):
        self.token = _spop(data, 'token')
        self.connectionKey = _spop(data, 'ck')
        self.packageName = _spop(data, 'pn')
        self.collapseKey = _spop(data, 'cp')
        self.payload = _spop(data, 'fbpushnotif')
        self.notificationId = _spop(data, 'nid')
        self.isBuffered = _spop(data, 'bu')
        self.viewId = _spop(data, 'view_id')
        self.numEndpoints = _spop(data, 'num_endpoints')
        self.timestamp = _spop(data, 'qt')

        # _spop(data, 'cc') # unknown
        # _spop(data, 'ndf') # unknown
        # _spop(data, 'bc_tigd') # unknown
        # _spop(data, 'bc_tint') # unknown
        # _spop(data, 'l') # unknown
        # _spop(data, 'j') # message id?

        if data:
            logger.debug('FBNSPush unexpected data: {data}'.format(**locals()))
Esempio n. 5
0
 def _on_fbns_message(self, payload):
     # It's instagram event
     logger.debug('[FBNS_MSG] {payload}'.format(**locals()))
     self.on_fbns_message(payload)
Esempio n. 6
0
 def _keep_connection(self):
     super()._keep_connection()
     logger.debug('[KEEP ALIVE]')