Ejemplo n.º 1
0
class Communicator():
    def __init__(self, messageHandler):

        # the tcp listener, that handles incoming connections on tcp.
        self.TCPReceiver = TCPReceiver("", 0, messageHandler)
        self.TCPReceiver.start()

        # the udp listener that gets broadcasting messages.
        self.UDPReceiver = UDPReceiver(6005, messageHandler)
        self.UDPReceiver.start()

        # the tcp and udp senders.
        self.TCPSender = TCPSender("", 0)
        self.UDPSender = UDPSender()

    # sends a message to one specific elevator.
    def sendToOne(self, peer, message):
        self.TCPSender.send(peer.IP, pickle.dumps(message))

    # Sends messages to all the elevators registered in this instance.
    def sendToAll(self, peerList, message):
        for peer in peerList:
            self.sendToOne(peer, message)

    # broadcasts messages on UDP, do not expect that It will arrive.
    def broadcast(self, message):
        self.UDPSender.send(pickle.dumps(message))
Ejemplo n.º 2
0
class Communicator():

    def __init__(self, messageHandler):

        # the tcp listener, that handles incoming connections on tcp.
        self.TCPReceiver = TCPReceiver("129.241.187.145", 0, messageHandler)
        self.TCPReceiver.start()

        # the udp listener that gets broadcasting messages.
        self.UDPReceiver = UDPReceiver(6005, messageHandler)
        self.UDPReceiver.start()

        # the tcp and udp senders.
        self.TCPSender = TCPSender("129.241.187.145", 0)
        self.UDPSender = UDPSender()

    # sends a message to one specific elevator.
    def sendToOne(self, peer, message):
        self.TCPSender.send(peer.IP, message)

    # Sends messages to all the elevators registered in this instance.
    def sendToAll(self, peerList, message):
        for peer in peerList:
            self.sendToOne(peer, message)

    # broadcasts messages on UDP, do not expect that It will arrive.
    def broadcast(self, message):
        self.UDPSender.send(message)
Ejemplo n.º 3
0
    def __init__(self, messageHandler):

        # the tcp listener, that handles incoming connections on tcp.
        self.TCPReceiver = TCPReceiver("", 0, messageHandler)
        self.TCPReceiver.start()

        # the udp listener that gets broadcasting messages.
        self.UDPReceiver = UDPReceiver(6005, messageHandler)
        self.UDPReceiver.start()

        # the tcp and udp senders.
        self.TCPSender = TCPSender("", 0)
        self.UDPSender = UDPSender()
Ejemplo n.º 4
0
    def __init__(self, messageHandler):

        # the tcp listener, that handles incoming connections on tcp.
        self.TCPReceiver = TCPReceiver("129.241.187.145", 0, messageHandler)
        self.TCPReceiver.start()

        # the udp listener that gets broadcasting messages.
        self.UDPReceiver = UDPReceiver(6005, messageHandler)
        self.UDPReceiver.start()

        # the tcp and udp senders.
        self.TCPSender = TCPSender("129.241.187.145", 0)
        self.UDPSender = UDPSender()