Package lacewing :: Package packetloaders :: Module channellist
[frames] | no frames]

Source Code for Module lacewing.packetloaders.channellist

 1  """ 
 2  Channel listing 
 3  """ 
 4   
 5  from struct import unpack_from, pack 
 6   
 7  from lacewing.baseloader import _BaseLoader, _EmptyLoader 
 8   
9 -class ChannelListRequest(_EmptyLoader):
10 """ 11 Used to request a channel list from the server 12 """
13
14 -class ChannelList(_BaseLoader):
15 """ 16 Sent for every channel on the server to the 17 client requesting 18 """ 19 count = None 20 name = None 21
22 - def read(self, data):
23 self.count, = unpack_from('<h', data) 24 self.name = data[2:]
25
26 - def isLast(self):
27 """ 28 Returns True if this packet was sent to tell the client 29 that there are no more channels to follow. 30 """ 31 return self.count == -1
32
33 - def setLast(self):
34 """ 35 Sets this packet to denote there are no more channels to follow. 36 """ 37 self.name = '' 38 self.count = -1
39
40 - def generate(self):
41 return pack('<h', self.count) + self.name
42 43 __all__ = ['ChannelListRequest', 'ChannelList'] 44