In a previous question of mine i get this answer:
Subclass twisted.conch.recvline.HistoricRecvLine instead of twisted.protocols.basic.LineReceiver. keystrokeReceived is one of the several additional protocol callbacks available when you are using a terminal instead of a TCP connection. – Jean-Paul Calderone Which is fine.
But what if what to have both terminal and TCP Connection? When i subclass HistoricRecvLine i loose the functionality of the TCP connection? So lets start it from the begging. My py file is:
class WebCheckerCommandProtocol(basic.LineReceiver):
def connectionMade(self):
self.sendLine("checker console. Type 'help' for help.")
def lineReceived(self, line):
...
def connectionLost(self, reason):
# stop the reactor, only because this is meant to be run in Stdio.
reactor.stop()
def do_listservers(self):
"Cmd to Query all available Servers - Takes no arguments"
conn = httplib.HTTPConnection(ip+":"+port)
conn.request(.....)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
def do_sessions(self):
conn = httplib.HTTPConnection(ip+":"+port)
conn.request(.....)
def do_logUser(self, name):
conn = httplib.HTTPConnection(ip+":"+port)
conn.request(.....)
class SimpleServer(LineReceiver):
def connectionMade(self):
print 'Connection from: ', self.transport.client
def connectionLost(self, reason):
print self.transport.client, 'Disconnected'
def dataReceived(self, line):
"""Here the XML Parser"""
print line
if __name__ == "__main__":
factory = Factory()
factory.protocol = SimpleServer
stdio.StandardIO(SimpleServer())
reactor.listenTCP(1234, factory)
reactor.run()
How to enable command history? How do i combine all that you suggest me to achieve what i want? cause i still can't. Obviously i'm missing something! Thanks in advance Antonis Kaklis