コード例 #1
0
	def handle(self):
		stream = self.request.makefile()
		stream.client_address = self.client_address
		while True:
			try:
				packet, stream = Packet.deserialize(stream)
			except:
				break
			self.server.trigger('data', packet, stream)
コード例 #2
0
def test_round_trip():
    from pyec.packet import Packet, Int
    import random
    import io

    class TestPacket(Packet):
        x = Int()
        y = Int()

    for _ in range(400):
        p = TestPacket(random.randrange(100000), random.randrange(100000))
        assert Packet.deserialize(io.BytesIO(p.serialize())) == p
コード例 #3
0
ファイル: test_packet.py プロジェクト: tuomas56/pyec
def test_round_trip():
    from pyec.packet import Packet, Int
    import random
    import io

    class TestPacket(Packet):
        x = Int()
        y = Int()

    for _ in range(400):
        p = TestPacket(random.randrange(100000), random.randrange(100000))
        assert Packet.deserialize(io.BytesIO(p.serialize())) == p