Ejemplo n.º 1
0
def test_decode():
    # Test string decode
    eq_(proto.decode(proto.encode('abc')), [('~m~', 'abc')])

    # Test unicode decode
    eq_(proto.decode(proto.encode(u'\u0430\u0431\u0432')),
        [('~m~', u'\u0430\u0431\u0432'.encode('utf-8'))])

    # Test JSON decode
    eq_(proto.decode(proto.encode({'a': 'b'})), [('~m~', {'a': 'b'})])

    # Test seprate messages decoding
    eq_(proto.decode(proto.encode(['a', 'b'])), [('~m~', 'a'), ('~m~', 'b')])
Ejemplo n.º 2
0
def test_decode():
    # Test string decode
    eq_(proto.decode(proto.encode('abc')), [('~m~', 'abc')])

    # Test unicode decode
    eq_(proto.decode(proto.encode(u'\u0430\u0431\u0432')),
        [('~m~', u'\u0430\u0431\u0432'.encode('utf-8'))])

    # Test JSON decode
    eq_(proto.decode(proto.encode({'a':'b'})),
        [('~m~', {'a':'b'})])

    # Test seprate messages decoding
    eq_(proto.decode(proto.encode(['a','b'])),
        [('~m~', 'a'), ('~m~', 'b')])
Ejemplo n.º 3
0
 def raw_message(self, message):
     """Called when raw message was received by underlying transport protocol
     """
     for msg in proto.decode(message):
         if msg[0] == proto.FRAME or msg[0] == proto.JSON:
             self.on_message(msg[1])
         elif msg[0] == proto.HEARTBEAT:
             # TODO: Verify incoming heartbeats
             logging.debug('Incoming Heartbeat')
Ejemplo n.º 4
0
 def raw_message(self, message):
     """Called when raw message was received by underlying transport protocol
     """
     for msg in proto.decode(message):
         if msg[0] == proto.FRAME or msg[0] == proto.JSON:
             self.on_message(msg[1])
         elif msg[0] == proto.HEARTBEAT:
             # TODO: Verify incoming heartbeats
             logging.debug("Incoming Heartbeat")
             self._missed_heartbeats -= 1