示例#1
0
文件: msg.py 项目: zmoon111/CUP
 def set_body(self, body):
     """
     set msg body
     """
     misc.check_type(body, str)
     self._data['body'] = body
     self._bodylen = len(body)
示例#2
0
文件: msg.py 项目: zmoon111/CUP
 def _addr2pack(self, ip_port, stub_future):
     misc.check_type(ip_port, tuple)
     misc.check_type(stub_future, tuple)
     pack = common.ip_port2connaddr(ip_port)
     pack = common.add_stub2connaddr(pack, stub_future[0])
     pack = common.add_future2connaddr(pack, stub_future[1])
     return pack
示例#3
0
文件: msg.py 项目: zmoon111/CUP
 def set_msg_type(self, msg_type):
     """
     set msg type
     """
     misc.check_type(msg_type, int)
     self._data['type'] = self._asign_uint2byte_bybits(msg_type, 32)
     self._type = msg_type
示例#4
0
def ip_port2connaddr(peer):
    """
    connaddr是个64bit的int
        32 -  16    - 16   - 32
        ip - port   - stub - future
    该函数以peer(ipaddr, port)为输入参数, 生成一个connaddr
    """
    misc.check_type(peer, tuple)
    ipaddr, port = peer
    misc.check_type(ipaddr, str)
    packed = socket.inet_aton(ipaddr)
    return ((struct.unpack("!L", packed)[0] << 64) | (port << 48))
示例#5
0
文件: common.py 项目: jinjin123/CUP
def ip_port2connaddr(peer):
    """
    connaddr is a 64bit int
        32 -  16    - 16   - 32
        ip - port   - stub - future

    :param peer:
        (ipaddr, port)
    :return:
        return a connaddr
    """
    misc.check_type(peer, tuple)
    ipaddr, port = peer
    misc.check_type(ipaddr, str)
    packed = socket.inet_aton(ipaddr)
    return (struct.unpack("!L", packed)[0] << 64) | (port << 48)
示例#6
0
def check_type(param, expect):
    """
    同cup.util.misc.check_type. 请使用前者
    """
    misc.check_type(param, expect)
示例#7
0
文件: msg.py 项目: zmoon111/CUP
 def _check_addr(cls, ip_port, stub_future):
     ip, port = ip_port
     stub, future = stub_future
     misc.check_type(ip, str)
示例#8
0
文件: __init__.py 项目: intohole/CUP
def check_type(param, expect):
    """
    同cup.util.misc.check_type. 请使用前者
    """
    misc.check_type(param, expect)
示例#9
0
def check_type(param, expect):
    """
    deprecated. Recommand using misc.check_type in cup.util
    """
    misc.check_type(param, expect)