| Home | Trees | Indices | Help |
|
|---|
|
|
A Client manages the connection to a Server instance elsewhere.
Creating an instance of a Client and connecting to a server is done as shown in the minimalist example below:
client = Client()
# Server is running on localhost port 9000
client.connect(('localhost', 9000))
# This loop ensures that .update() is called.
while True:
client.update()
# Add a small time delay to prevent pegging the CPU.
time.sleep(0.0001)
The Client has a number of events that can be hooked into that provide notifications of data sent from the server and state changes. An event consists of the sender and the argument(in the example below, this is the message), eg:
def my_message_handler(sender, message):
print "The greeting reads: %s" % message.greeting.value
my_client.OnMessage += my_message_handler
For the Client.OnMessage handler example above the argument part of the
event received is a re-assembled instance of the message that was sent, and
the greeting field in the message is obtained via
the fields value attribute.
has been responded to by the server allowing the connection.
has been responded to by the server deneying the connection.
See above example.
detailing the error.
Server. If the connection was severed due to a time-out, the Client.OnError event would fire.
| Classes | |
| ClientError | |
| Client |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Jul 04 00:49:02 2010 | http://epydoc.sourceforge.net |