Пример #1
0
    def send(self):
        myself = Subscriber()
        myself.port = DEFAULT_PORT  # sender port
        myself.ip = 'localhost'
        myself.id = 'sender'

        message = Message()
        message.type = 'subscription'
        message.senderID = 'sender'
        message.receiverID = 'receiver'
        message.body = myself

        self.netWriter.write('broker', message)

        message.type = 'message'

        while True:
            text = raw_input("Enter message to send: ")
            if text == 'close':
                self.netWriter.close_socket()
                break
            recipient = raw_input('Enter receiver: ')
            message.body = text
            message.receiverID = recipient
            self.netWriter.write('receiver', message)
        return
Пример #2
0
    def send(self):
        myself = Subscriber()
        myself.port = DEFAULT_PORT
        myself.ip = 'localhost'
        myself.id = 'sender'

        message = Message()
        message.type = 'subscription'
        message.senderID = 'sender'
        message.receiverID = 'receiver'
        message.body = myself

        self.netWriter.write('broker', message)
Пример #3
0
    def send(self):
        myself = Subscriber()
        myself.port = DEFAULT_PORT
        myself.ip = 'localhost'
        myself.id = 'app2'

        message = Message()
        message.type = 'subscription'
        message.senderID = 'app2'
        message.receiverID = 'broker'
        message.body = myself

        self.netWriter.write('broker', message)
Пример #4
0
    def send(self):
        myself = Subscriber()
        myself.port = DEFAULT_PORT  # sender port
        myself.ip = 'localhost'
        myself.id = 'app1'

        message = Message()
        message.type = 'subscription'
        message.senderID = 'app1'
        message.receiverID = 'broker'
        message.body = myself

        self.netWriter.write('broker', message)

        message.type = 'message'
        tree = ET.parse('country_data.xml')
        root = tree.getroot()

        recipient = 'app2'
        message.body = open('country_data.xml').read()
        message.receiverID = recipient
        self.netWriter.write('app2', message)