本文整理汇总了Python中Packet.setSessionId方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.setSessionId方法的具体用法?Python Packet.setSessionId怎么用?Python Packet.setSessionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.setSessionId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: receive
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import setSessionId [as 别名]
def receive( self ):
#receive a single header from yahoo
header = self.sock.recv( HEADER_SIZE )
if header == '':
raise IOError, "Connection broken by yahoo"
#find the length of the payload
lengthstring = header[ 8:10 ]
lengthstring = struct.unpack( '>H', lengthstring )
length = int( lengthstring[ 0 ] )
#what kind of packet is this?
if len( header ) > 10:
type = header[ 11 ]
else:
type = "unknown"
#deal with the login ack packet as a special case, since it requires info from the header
if type == "W":
sessionid = header[ 16 : 20 ]
Packet.setSessionId( sessionid )
if PACKETTYPES.has_key( type ):
#print "Known packet type: ",
ctor = PACKETTYPES[ type ]
packet = ctor( self.sock, self.room, length )
else:
#default - do nothing
print "Unknown packet type: %02x" % ord(type)
packet = Ack.AckPacket( self.sock, None, length )
# Packet.printPacket( header )
return packet