From afd30708f3a9e6b42d9dc3c77d007707ccc09e12 Mon Sep 17 00:00:00 2001 From: Swann Date: Mon, 4 Feb 2019 13:53:38 +0100 Subject: [PATCH] [rfc] cleanup --- main.py | 3 +++ net_components.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 3e18882..b0905e0 100644 --- a/main.py +++ b/main.py @@ -5,10 +5,12 @@ import zmq import sys import argparse import time +import asyncio # TODO: Implement a manager class for each aspect (ex: Network_Manager) # TODO: Is it right to implement server-client as ESC ?... +@asyncio.coroutine def main(): # Argument parsing parser = argparse.ArgumentParser( @@ -38,6 +40,7 @@ def main(): world.add_component( session, net_components.User(role=instance_role)) + # A dummy main loop: try: while True: diff --git a/net_components.py b/net_components.py index e923375..d9f21e9 100644 --- a/net_components.py +++ b/net_components.py @@ -1,4 +1,6 @@ import zmq +# from zmq.asyncio import Context, ZMQEventLoop +# import asyncio from enum import Enum, auto class Role(Enum): @@ -20,7 +22,7 @@ class User: self.role = role class NetworkInterface: - def __init__(self, host="127.0.0.1",context=None, socket_type=zmq.REP,protocol='tcp',port=5555): + def __init__(self, host="*",context=None, socket_type=zmq.REQ,protocol='tcp',port=5555): self.host = host self.context = context self.socket = context.socket(socket_type) @@ -28,7 +30,8 @@ class NetworkInterface: #TODO: Is this right to it here? self.poller.register(self.socket, zmq.POLLIN) - self.socket.bind("{}://{}:{}".format(protocol,host,port)) + print("{}://{}:{}".format(protocol,host,port)) + self.socket.bind("tcp://*:5555") class Property: def __init__(self, property=None, replication=Replication.NONE):