Created
August 13, 2018 13:07
-
-
Save biancarosa/26f52dbbeadfa63d725d561eafa52a0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import Pyro4 | |
@Pyro4.expose | |
class Chat(object): | |
def send_message(self, text): | |
now = datetime.now() | |
print(f'{text} - received at {now:%H:%M:%S} \n') | |
def start_server(): | |
daemon = Pyro4.Daemon() | |
ns = Pyro4.locateNS() | |
uri = daemon.register(Chat) | |
ns.register('mess.server', str(uri)) | |
print(f'Ready to listen') | |
daemon.requestLoop() | |
if __name__ == '__main__': | |
try: | |
start_server() | |
except (KeyboardInterrupt, EOFError): | |
print('Goodbye! (:') | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment