I am doing a gps tracker wich use multiple protocols and multiple clients, my problen is when I have more than one client on more than one protocol at the same time, data and validation start to crashing one to other
My Server is #!/usr/bin/env python # -*- coding: utf-8 -*- """Heracles Tracker Listener Server.""" from twisted.internet import threads from twisted.protocols.gps.nmea import NMEAReceiver from twisted.internet.protocol import Factory, Protocol import binascii #class TrackerServer(NMEAReceiver): #class TrackerServer(LineReceiver): class TrackerServer(Protocol): """Tracker Twisted Protocol Class.""" def __init__(self, decoder): """Class Constructor.""" decoderModule = __import__('listener.protocols.%sDecoder' % (decoder, ), fromlist=['%sDecoder' % (decoder, )]) decoderClass = getattr(decoderModule, '%sDecoder' % (decoder, )) self.decoder = decoderClass() #self.delimiter = '0'; def connectionMade(self): """ConnectionMade Twisted event.""" try: print 'Connection made to', self.transport.getHost(), 'from', self.transport.getPeer() except ValueError: print "Oops! Connection was not started" def connectionLost(self, reason): """ConnectionLost Twisted event.""" print "Connection lost ", reason def dataReceived(self, data): Protocol.dataReceived(self, data) """DataReceived Twisted event.""" try: self.sendResponse(self.decoder.processDatagram(data)) #d = threads.deferToThread(self.decoder.processDatagram(data )) #d.addCallback(self.sendResponse) except ValueError: print "Oops! That was no valid data. Try again..." def sendResponse (self, response): self.transport.write(response) class TrackerFactory(Factory): """Tracker Factory Twisted Class.""" def __init__(self, decoder): """Class Constructor. """ self.decoder = decoder def buildProtocol(self, addr): """BuildProtocol Twisted.""" return TrackerServer(self.decoder) My tac file is #!/usr/bin/env python # -*- coding: utf-8 -*- import os, sys import ConfigParser from twisted.application import internet, service from listener.TrackerServer import TrackerFactory PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) sys.path.append(PROJECT_DIR) path = None config = ConfigParser.ConfigParser() config.read('protocols.cfg') application = service.Application("tracker") for protocol in config.get('protocols', 'keys').split(','): port = int(config.get(protocol, 'port')) factory = TrackerFactory(config.get(protocol, 'name')) trackerService = internet.TCPServer(port, factory) # create the service trackerService.setServiceParent(application) -- Carlos Eduardo Sotelo Pinto | http://carlossotelo.com | csotelo@twitter GNU Linux Admin | PHP Senior Web Developer Mobil: RPC (Claro)+51, 958194614 | Mov: +51, 959980794 GTalk: carlos.sotelo.pi...@gmail.com | Skype: csotelop MSN: carlos.sotelo.pi...@gmail.com | Yahoo: csotelop GNULinux RU #379182 | GNULinux RM #277661 GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python