Example #1
0
class Client(threading.Thread):
	def __init__(self, receiveCallback = None):
		self.logger = module_logger.getChild(self.__class__.__name__)
		self.receiveCallback = receiveCallback
		self.factory = ClientFactory(self.receiveCallback)
		threading.Thread.__init__(self)
		
	def setup(self, host, port):
		self.endpoint = TCP4ClientEndpoint(reactor, host, port)
		self.endpoint.connect(self.factory)
		
	def run(self):
		self.logger.debug('Connecting.....')
		reactor.run(installSignalHandlers=0)

	def send(self, line):
		self.factory.send(line)
		
		
	def stop(self):
		reactor.callFromThread(reactor.stop)
		
	def join(self):
		self.stop()
		threading.Thread.join(self)
Example #2
0
	def __init__(self, receiveCallback = None):
		self.logger = module_logger.getChild(self.__class__.__name__)
		self.receiveCallback = receiveCallback
		self.factory = ClientFactory(self.receiveCallback)
		threading.Thread.__init__(self)