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

Source Code for Module lacewing.packetloaders.peermessage

 1  from struct import unpack_from, pack, calcsize 
 2   
 3  from lacewing.baseloader import _BaseLoader 
 4   
 5  from lacewing.packetloaders.common import _DataTypeMixin, _ChannelMessage 
 6   
7 -class PeerMessage(_ChannelMessage):
8 """ 9 This is sent by the server to to tell a recipient client 10 that another client has sent a message to it 11 The server can edit the message value if it wants to (or completely 12 block it). 13 """
14
15 -class SendPrivate(_BaseLoader, _DataTypeMixin):
16 """ 17 This is used by the client to send a message 18 to a specific recipient. 19 20 @ivar channelId: The channel ID 21 @ivar subchannel: The subchannel of the message 22 @ivar recipientId: The destinated recipient ID 23 @ivar value: The message contents. 24 @type value: str or number 25 """ 26 27 channelId = None 28 subchannel = None 29 recipientId = None 30 value = None 31
32 - def read(self, data):
33 (self.channelId, 34 self.recipientId, 35 self.subchannel) = unpack_from('<HHB', data) 36 self.readMessage(data, 5)
37
38 - def generate(self):
39 data = pack('<HHB', 40 self.channelId, 41 self.recipientId, 42 self.subchannel) 43 return data + self.generateMessage()
44 45 __all__ = ['PeerMessage', 'SendPrivate'] 46