Example #1
0
from pokernetwork.protocol import log as protocol_log
log = protocol_log.get_child('binarypack')

from pokernetwork.protocol._base import BaseProtocol

from pokerpackets import binarypack
from pokerpackets.binarypack._binarypack import S_PACKET_HEAD

from pokernetwork import protocol_number
from pokernetwork.version import Version
protocol_version = Version(protocol_number)
protocol_handshake = 'CGI %03d.%d%02d\n' % protocol_version.version


class UGAMEProtocol(BaseProtocol):

    log = log.get_child('UGAMEProtocol')

    def __init__(self):
        BaseProtocol.__init__(self)

        self._data = b""
        self._out_buffer = [
        ]  # as long as not established outgoing packets are buffered

        self._cur_packet_length = None  # None: not currently on any packet
        self._ignore_incoming = False

    def connectionMade(self):
        self._sendVersion()
Example #2
0
from pokernetwork.protocol import log as protocol_log
log = protocol_log.get_child('msgpack')

import pokerpackets.networkpackets
from pokerpackets.packets import type_id2type, name2type
from pokerpackets.dictpack import pack
from pokernetwork.util.trace import format_exc

import msgpack as _msgpack

from pokernetwork.protocol._base import BaseProtocol

class MsgpackProtocol(BaseProtocol):

    log = log.get_child('MsgpackProtocol')

    def __init__(self):
        BaseProtocol.__init__(self)

        self._numeric_type = True
        self._unpacker = _msgpack.Unpacker()
        self._packer = _msgpack.Packer()

    def dataReceived(self, data):
        self._unpacker.feed(data)

        for p_type_id, p_dict in self._unpacker:
            if isinstance(p_type_id, int):
                self._numeric_type = True
                self.packetReceived(type_id2type[p_type_id](**p_dict))
Example #3
0
from pokernetwork.protocol import log as protocol_log
log = protocol_log.get_child('msgpack')

import pokerpackets.networkpackets
from pokerpackets.packets import type_id2type, name2type
from pokerpackets.dictpack import pack
from pokernetwork.util.trace import format_exc

import msgpack as _msgpack

from pokernetwork.protocol._base import BaseProtocol


class MsgpackProtocol(BaseProtocol):

    log = log.get_child('MsgpackProtocol')

    def __init__(self):
        BaseProtocol.__init__(self)

        self._numeric_type = True
        self._unpacker = _msgpack.Unpacker()
        self._packer = _msgpack.Packer()

    def dataReceived(self, data):
        self._unpacker.feed(data)

        for p_type_id, p_dict in self._unpacker:
            if isinstance(p_type_id, int):
                self._numeric_type = True
                self.packetReceived(type_id2type[p_type_id](**p_dict))
Example #4
0
from pokernetwork.protocol import log as protocol_log
log = protocol_log.get_child('binarypack')

from pokernetwork.protocol._base import BaseProtocol

from pokerpackets import binarypack
from pokerpackets.binarypack._binarypack import S_PACKET_HEAD

from pokernetwork import protocol_number
from pokernetwork.version import Version
protocol_version = Version(protocol_number)
protocol_handshake = 'CGI %03d.%d%02d\n' % protocol_version.version

class UGAMEProtocol(BaseProtocol):

    log = log.get_child('UGAMEProtocol')

    def __init__(self):
        BaseProtocol.__init__(self)

        self._data = b""
        self._out_buffer = [] # as long as not established outgoing packets are buffered

        self._cur_packet_length = None # None: not currently on any packet
        self._ignore_incoming = False

    def connectionMade(self):
        self._sendVersion()

    def dataReceived(self, data):