Home | Trees | Indices | Help |
|
---|
|
1 """ 2 Initial connection request and reply. 3 """ 4 5 from struct import unpack_from, pack 6 7 from lacewing.constants import IMPLEMENTATION_TYPES 8 from lacewing.baseloader import _BaseLoader 9 from lacewing.bitdict import BitDict 1012 """ 13 This is a reply to the client connection request. 14 It tells the client what settings are set at the server. 15 16 Use the methods to manipulate properties (if available). 17 18 @ivar flags: The settings specified by the server 19 @type flags: BitDict 20 """ 21 flags = None 22 message = None 23 serverType = None 246026 self.flags = BitDict( 27 'UDP', 28 None, # reserved 29 None, # reserved 30 'Ping', 31 'ChannelListing', 32 'Extensions', 33 default = False 34 )3537 """ 38 Return the server type as a string. 39 @return: See L{IMPLEMENTATION_TYPES}. 40 """ 41 return IMPLEMENTATION_TYPES[self.serverType]4244 """ 45 Set the type of this server from string. 46 @param serverType: Server type as string, see L{IMPLEMENTATION_TYPES}. 47 """ 48 print serverType 49 self.serverType = IMPLEMENTATION_TYPES.index(serverType)5052 flags, serverType = unpack_from('<IB', data) 53 self.flags.setFlags(flags) 54 self.serverType = serverType 55 self.message = data[5:]5662 """ 63 This is the initial connection request sent 64 by the client. If it does not send this request within 65 reasonable time, it is disconnected. 66 67 Use the methods to manipulate properties (if available). 68 69 @ivar flags: Settings specified the client. It might, for example, 70 not want to get messaged privately. 71 72 @ivar protocolVersion: This is the protocol version that 73 the client can communicate with. The server might 74 want to disconnect the client if it does not support this 75 version. 76 """ 77 flags = None 78 protocolVersion = None 79 clientType = None 80 extensions = None 81 90119 120 __all__ = ['Hello', 'Welcome'] 12192 (flags, 93 self.protocolVersion, 94 self.clientType) = unpack_from('<IBB', data) 95 self.flags.setFlags(flags) 96 self.extensions = data[6:].split('\x00')9799 """ 100 Return the client type as a string. 101 @return: See L{IMPLEMENTATION_TYPES}. 102 """ 103 return IMPLEMENTATION_TYPES[self.clientType]104106 """ 107 Set the type of this client from string. 108 @param clientType: Client type as string, see L{IMPLEMENTATION_TYPES}. 109 """ 110 self.clientType = IMPLEMENTATION_TYPES.index(clientType)111113 # because Jamie is such a sex god (no question) and made 114 # the client flags in the first place, we're sending 115 # compatibility flags here 116 compatibleFlags = 0b1111 117 return pack('<IBB', compatibleFlags, self.protocolVersion, 118 self.clientType) + '\x00'.join(self.extensions or ())
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Sep 16 22:07:42 2010 | http://epydoc.sourceforge.net |