Exemplo n.º 1
0
class RxPClient:
    def __init__(self, ip, port):
        self.ip = ip
        self.port = port
        if self.ip == "":
            self.ip = "127.0.0.1"
        if self.port == "":
            self.port = random.randint(30000, 33000)
        self.socket = RxPSocket(self.ip, self.port, 1024)

    def connect(self, NetEmu_IP, NetEmu_Port):
        logging.debug("[DEBUG] RxP client is trying to connect to netEmu. Ran from the RxPClient class")
        self.socket.connect(NetEmu_IP, NetEmu_Port)
        # self.socket.send("Hello world!")
        # method stub for connect called from the client side

    # TODO: Implementing this command before RxPSocket has been coded. Make sure this works after coding that up.
    # data, recipient_ip, recipient_port
    def post(self, data):
        # recipient_ip = self.address[0]
        # recipient_port = self.address[1]
        recipient_ip = self.ip
        recipient_port = self.port

        # TODO: Implement send(data, recipient_ip, recipient_port) in RxPSocket class
        # super.send(data, recipient_ip, recipient_port)

    def get(self, filename):
        print("Get called in RxPClient.py. wants file: " + filename)
        packetData = "GET:" + filename
        # TODO: The following is broken.
        self.socket.receive(filename)

    def setWindow(self, window):
        return ""