Example #1
0
 def receptor(barrera):
     connector = ChatServerConnector('localhost', 6500, 12)
     barrera.wait()
     news = connector.get_news()
     while not news:
         news = connector.get_news()
     assert len(news) == 1
     assert news[0].message.sender == 11
     exit(0)
Example #2
0
def keep_update(ip, port, id, news_sender, messages_receiver):
    csc = ChatServerConnector(host=args.ip, port=args.port, id=args.id)
    while True:
        news = csc.get_news()
        if news:
            news_sender.send(news)
        if messages_receiver.poll(0.1):
            message = messages_receiver.recv()
            csc.send_message(message)
Example #3
0
 def __call__(self) -> NoReturn:
     """
     Runs the process
     """
     connector = ChatServerConnector('localhost', 6500, self.client_id)
     self.barrier.wait()
     for message in self.messages_to_send:
         connector.send_message(message)
     while self.expecting_more_news():
         news = connector.get_news()
         for new in news:
             if isinstance(new, NewMessage):
                 self.messages_received.append(new.message)
             elif isinstance(new, ReceiptNotice):
                 self.messages_with_receipt_notice.update([new.message_id])
             else:
                 continue
     exit(0)
Example #4
0
 def escritor(barrera):
     connector = ChatServerConnector('localhost', 6500, 11)
     connector.send_message(TextMessage(11, 999, "Hola amiwi"))
     barrera.wait()
     message = TextMessage(11, 12, "Hola don pepito")
     connector.send_message(message)
     news = connector.get_news()
     while not news:
         news = connector.get_news()
     assert len(news) == 1
     assert news[0].message_id == message.message_id
     exit(0)
Example #5
0
        def pepito(barrera):
            def dummy_get_news(connector):
                new_data = connector.blocking_socket_transferer.receive_plain_text(
                )

            connector = ChatServerConnector('localhost', 6500, 14)
            barrera.wait()
            dummy_get_news(connector)
            sleep(20)
            news = [
                new for new in connector.get_news()
                if isinstance(new, NewMessage)
            ]
            while not news:
                news = [
                    new for new in connector.get_news()
                    if isinstance(new, NewMessage)
                ]
            assert len(news) == 1
            assert news[0].message.content == "Hola don pepito"
            sleep(30)
            assert not connector.get_news()
            exit(0)
Example #6
0
 def pepito(barrera):
     connector = ChatServerConnector('localhost', 6500, 7)
     barrera.wait()
     connector.send_message(TextMessage(7, 8, "Hola jorgito"))
     news = [
         new for new in connector.get_news()
         if isinstance(new, NewMessage)
     ]
     while not news:
         news = [
             new for new in connector.get_news()
             if isinstance(new, NewMessage)
         ]
     assert len(news) == 1
     assert news[0].message.sender == 8
     assert news[0].message.content == "Hola don pepito"
     exit(0)
Example #7
0
 def jorgito(barrera):
     connector = ChatServerConnector('localhost', 6500, 13)
     barrera.wait()
     connector.send_message(TextMessage(13, 14, "Hola don pepito"))
     exit(0)