Skip to content

StupidIncarnate/libtpproto-py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro
==============================================
This provides all the necessary objects to talk to the Thousand Parsec protocol. 

Support Libraries
==============================================
For basic Thousand Parsec functionality no extra Python libraries are needed. 

It is recommened to install either if you are running a server,
	python-pyopenssl
	m2crypto
or one of the following if you are running a client,
	python-pyopenssl
	m2crypto
	TLS Lite

Installing these libraries will improve SSL support.

Clients will not be able to connect to TLS enabled Thousand Parsec servers (but
it should be able to connect to SSL3 and SSL2 servers) without one of these
libraries.

Servers will not be able to serve SSL connections (or tunnel HTTPS connections)
without one of these libraries.

Library
==============================================
The library can run in either non-blocking or blocking mode.

In blocking mode operations preformed on the connection will wait for the
results to become available before returning. It will never return None.

In non-blocking mode operations preformed on the connection will return nothing.
The connection must be until the result is obtained.  It is safe to preform more
operations on the connection before the connection has returned the result, no
answer will be lost.

Poll will return None until the complete response is available. Poll will return
the answers in the same order that the actions where preformed. 

If you want to wait for an action to complete you can use wait which will wait
until the result if ready and return it. Wait will never return None.

Blocking Example Usage:

>>>
>>> import sys
>>>
>>> from tp import netlib
>>>
>>> # Create the object and connect to the server
>>> c = netlib.Connection("127.0.0.1", 6329)
>>> if not c.connect():
>>>    print "Could not connect to the server"
>>>    sys.exit(1)
>>>
>>> if not c.login("username", "password"):
>>> 	print "Could not login"
>>> 	sys.exit(1)
>>>

Non-Blocking Example Usage:

>>>
>>> import sys
>>>
>>> from tp import netlib
>>>
>>> # Create the object and connect to the server
>>> c = netlib.Connection("127.0.0.1", 6329)
>>>
>>> c.connect()
>>> c.login("username", "password")
>>>
>>> # Wait for the connection to be complete
>>> if not c.wait():
>>>    print "Could not connect to the server"
>>>    sys.exit(1)
>>>
>>> r = c.poll()
>>> while r == None:
>>> 	r = c.poll()
>>>
>>> 	# Do some other stuff!
>>> 	pass
>>>
>>> if not r:
>>> 	print "Could not login"
>>> 	sys.exit(1)
>>>
>>> # Disconnect and cleanup
>>> c.disconnect()
>>>



About

A library for working with the Thousand Parsec protocol in Python. Supports development of both servers and clients.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published