PythonMayerEasyConnection000
From Wiki
This is the support page for Florian Mayer's easy_connection basics video set. Please feel free to dip-in and extend this information.
The home of the project is at sourceforge
If the link should be down, here are the sourcecodes
from easy_connection.client.connection import Connection
class Conn(Connection):
def __init__(self, ip, port=None):
Connection.__init__(self, ip=ip, port=port)
self.bind("TEST", self.onTest)
def onTest(self, event):
print "onTest called"
self.stop()
client = Conn("127.0.0.1:90000")
client.start()
client.send("ECHO TEST")
from easy_connection.server.server import Server
from easy_connection.server.connection import Connection
class Conn(Connection):
def __init__(self, channel, details, server, id):
Connection.__init__(self, channel, details, server, id)
print self.remote_ip
self.bind("ECHO", self.onEcho)
self.bind("BYE", self.onBye)
def onEcho(self, event):
self.send(event.arg)
def onBye(self, event):
self.stop(skipbye=True)
try:
server = Server(90000, 0, Conn)
server.run()
except KeyboardInterrupt:
server.killServer()
IMPORTANT NOTICE: server.killServer() is deprecated and was changed to server.kill(), although killServer() works too please use kill()

