コード例 #1
0
ファイル: session_test.py プロジェクト: purepython/tornadio2
def test_ack():
    # Create environment
    server, session, transport, conn = _get_test_environment()

    # Send message with ACK
    transport.recv(proto.message(None, 'abc', 1))

    # Check that message was received by the connection
    eq_(conn.pop_incoming(), 'abc')

    # Check for ACK
    eq_(transport.pop_outgoing(), '3:::abc')
    eq_(transport.pop_outgoing(), '6:::1')

    # Send with ACK
    def handler(message):
        eq_(message, 'abc')

        conn.send('yes')

    conn.send('abc', handler)

    eq_(transport.pop_outgoing(), '3:1::abc')

    # Send ACK from client
    transport.recv('6:::1')

    # Check if handler was called
    eq_(transport.pop_outgoing(), '3:::yes')
コード例 #2
0
def test_ack():
    # Create environment
    server, session, transport, conn = _get_test_environment()

    # Send message with ACK
    transport.recv(proto.message(None, 'abc', 1))

    # Check that message was received by the connection
    eq_(conn.pop_incoming(), 'abc')

    # Check for ACK
    eq_(transport.pop_outgoing(), '3:::abc')
    eq_(transport.pop_outgoing(), '6:::1')

    # Send with ACK
    def handler(message):
        eq_(message, 'abc')

        conn.send('yes')

    conn.send('abc', handler)

    eq_(transport.pop_outgoing(), '3:1::abc')

    # Send ACK from client
    transport.recv('6:::1')

    # Check if handler was called
    eq_(transport.pop_outgoing(), '3:::yes')
コード例 #3
0
 def run(self):
     message = {}
     message['type'] = 'datachanged'
     message['data'] = copy.copy(self.message)
     del message['data']['user']
     del message['data']['session']
     message = ujson.encode(message)
     for conn in CONNECTIONS:
         if conn.user and conn.user['username'] == self.message['user'] \
         and conn.session_id != self.message['session']:
             try:
                 conn.send(message)
             except Exception, e:
                 logging.error(
                     "Failed to send data change notification to session %s: %s"
                     % (conn.session_id, e))
コード例 #4
0
ファイル: server.py プロジェクト: skygeek/skyproc
 def run(self):
     message = {}
     message["type"] = "datachanged"
     message["data"] = copy.copy(self.message)
     del message["data"]["user"]
     del message["data"]["session"]
     message = ujson.encode(message)
     for conn in CONNECTIONS:
         if (
             conn.user
             and conn.user["username"] == self.message["user"]
             and conn.session_id != self.message["session"]
         ):
             try:
                 conn.send(message)
             except Exception, e:
                 logging.error("Failed to send data change notification to session %s: %s" % (conn.session_id, e))
コード例 #5
0
ファイル: session_test.py プロジェクト: ywjb/tornadio2
def test_ack():
    # Create environment
    server, session, transport, conn = _get_test_environment()

    # Send message with ACK
    transport.recv(proto.message(None, 'abc', 1))

    # Check that message was received by the connection
    eq_(conn.pop_incoming(), 'abc')

    # Check for ACK
    eq_(transport.pop_outgoing(), '3:::abc')
    eq_(transport.pop_outgoing(), '6:::1')

    # Send with ACK
    def handler(msg, data):
        eq_(msg, 'abc')
        eq_(data, None)

        conn.send('yes')

    conn.send('abc', handler)

    eq_(transport.pop_outgoing(), '3:1::abc')

    # Send ACK from client
    transport.recv('6:::1')

    # Check if handler was called
    eq_(transport.pop_outgoing(), '3:::yes')

    # Test ack with event
    # Send event with multiple parameters
    transport.recv(proto.event(None, 'test', 1, a=10, b=20))

    # Check outgoing
    eq_(transport.pop_outgoing(), proto.event(None, 'test', None, a=10, b=20))
    eq_(transport.pop_outgoing(), proto.ack(None, 1, 'test'))
コード例 #6
0
ファイル: session_test.py プロジェクト: legnaleurc/tornadio2
def test_ack():
    # Create environment
    server, session, transport, conn = _get_test_environment()

    # Send message with ACK
    transport.recv(proto.message(None, 'abc', 1))

    # Check that message was received by the connection
    eq_(conn.pop_incoming(), 'abc')

    # Check for ACK
    eq_(transport.pop_outgoing(), '3:::abc')
    eq_(transport.pop_outgoing(), '6:::1')

    # Send with ACK
    def handler(msg, data):
        eq_(msg, 'abc')
        eq_(data, None)

        conn.send('yes')

    conn.send('abc', handler)

    eq_(transport.pop_outgoing(), '3:1::abc')

    # Send ACK from client
    transport.recv('6:::1')

    # Check if handler was called
    eq_(transport.pop_outgoing(), '3:::yes')

    # Test ack with event
    # Send event with multiple parameters
    transport.recv(proto.event(None, 'test', 1, a=10, b=20))

    # Check outgoing
    eq_(transport.pop_outgoing(), proto.event(None, 'test', None, a=10, b=20))
    eq_(transport.pop_outgoing(), proto.ack(None, 1, 'test'))
コード例 #7
0
ファイル: session_test.py プロジェクト: purepython/tornadio2
    def handler(message):
        eq_(message, 'abc')

        conn.send('yes')
コード例 #8
0
    def handler(message):
        eq_(message, 'abc')

        conn.send('yes')
コード例 #9
0
ファイル: session_test.py プロジェクト: ywjb/tornadio2
    def handler(msg, data):
        eq_(msg, 'abc')
        eq_(data, None)

        conn.send('yes')
コード例 #10
0
ファイル: session_test.py プロジェクト: legnaleurc/tornadio2
    def handler(msg, data):
        eq_(msg, 'abc')
        eq_(data, None)

        conn.send('yes')
コード例 #11
0
ファイル: session_test.py プロジェクト: Gerrrr/tornadio2
    def handler(msg, data):
        eq_(msg, "abc")
        eq_(data, None)

        conn.send("yes")