Package legume :: Package udp :: Module client :: Class Client
[frames] | no frames]

type Client

               object --+    
                        |    
netshared.NetworkEndpoint --+
                            |
                           Client

Instance Methods
 
__init__(self, message_factory=MessageFactory())
Create a Client endpoint.
 
connect(self, address)
Initiate a connection to the server at the specified address.
 
disconnect(self)
Gracefully disconnect from the host.
 
sendMessage(self, message)
Send a message to the server.
 
sendReliableMessage(self, message)
Send a message to the server with guaranteed delivery.
 
update(self)
This method should be called frequently to process incoming data, send outgoing data, and raise events.
 
bindSocket(self, addr) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
connectSocket(self, addr) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
createSocket(self) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
doRead(self, callback) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
getSocket(self) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
getState(self) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
isActive(self) (Inherited from legume.udp.netshared.NetworkEndpoint)
 
setTimeout(self, timeout) (Inherited from legume.udp.netshared.NetworkEndpoint)
Class Variables
  CONNECTED = 104 (Inherited from legume.udp.netshared.NetworkEndpoint)
  CONNECTING = 103 (Inherited from legume.udp.netshared.NetworkEndpoint)
  DISCONNECTED = 100 (Inherited from legume.udp.netshared.NetworkEndpoint)
  ERRORED = 101 (Inherited from legume.udp.netshared.NetworkEndpoint)
  LISTENING = 102 (Inherited from legume.udp.netshared.NetworkEndpoint)
  MTU = 1400 (Inherited from legume.udp.netshared.NetworkEndpoint)
Properties
  connected
Returns True if this endpoint's state is CONNECTED.
  disconnected
Returns True if this endpoint's state is DISCONNECTED.
  errored
Returns True if this endpoint's state is ERRORED.
  is_server
Returns false.
  latency
  OnConnectRequestRejected
  OnMessage
  OnConnectRequestAccepted
  OnError
  OnDisconnect
  socket (Inherited from legume.udp.netshared.NetworkEndpoint)
  state (Inherited from legume.udp.netshared.NetworkEndpoint)
  timeout (Inherited from legume.udp.netshared.NetworkEndpoint)
Method Details

__init__(self, message_factory=MessageFactory())
(Constructor)

 

Create a Client endpoint. A Client is initially in the closed state until a call to connect.

A messages factory is required to assemble and disassemble messages for pushing down the intertubes to the server endpoint. If a message_factory is not explicitly specified then the global message_factory will be used.

Parameters:
Overrides: netshared.NetworkEndpoint.__init__

connect(self, address)

 

Initiate a connection to the server at the specified address.

This method will put the socket into the CONNECTING state. If a connection is already established a ClientError exception is raised.

Parameters:
  • address ((host, port)) - Host address

disconnect(self)

 
Gracefully disconnect from the host. A disconnection packet is sent to the server upon calling the .update() method. The connection status of the class instance will not changed to DISCONNECTED until .update() is called.

sendMessage(self, message)

 
Send a message to the server. The message is added to the output buffer. To flush the output buffer call the .update() method. If the client is not connected to the server a ClientError exception is raised.
Parameters:

sendReliableMessage(self, message)

 
Send a message to the server with guaranteed delivery. If the client is not connected to the server a ClientError exception is raised.
Parameters:

Property Details

connected

Returns True if this endpoint's state is CONNECTED.

disconnected

Returns True if this endpoint's state is DISCONNECTED.

errored

Returns True if this endpoint's state is ERRORED.

is_server

Returns false.

latency

OnConnectRequestRejected

Get Method:
_getOnConnectRequestRejected(self)
Set Method:
_setOnConnectRequestRejected(self, event)

OnMessage

Get Method:
_getOnMessage(self)
Set Method:
_setOnMessage(self, event)

OnConnectRequestAccepted

Get Method:
_getOnConnectRequestAccepted(self)
Set Method:
_setOnConnectRequestAccepted(self, event)

OnError

Get Method:
_getOnError(self)
Set Method:
_setOnError(self, event)

OnDisconnect

Get Method:
_getOnDisconnect(self)
Set Method:
_setOnDisconnect(self, event)