[rfc] cleanup
This commit is contained in:
3
main.py
3
main.py
@ -5,10 +5,12 @@ import zmq
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
# TODO: Implement a manager class for each aspect (ex: Network_Manager)
|
# TODO: Implement a manager class for each aspect (ex: Network_Manager)
|
||||||
# TODO: Is it right to implement server-client as ESC ?...
|
# TODO: Is it right to implement server-client as ESC ?...
|
||||||
|
@asyncio.coroutine
|
||||||
def main():
|
def main():
|
||||||
# Argument parsing
|
# Argument parsing
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -38,6 +40,7 @@ def main():
|
|||||||
world.add_component(
|
world.add_component(
|
||||||
session, net_components.User(role=instance_role))
|
session, net_components.User(role=instance_role))
|
||||||
|
|
||||||
|
|
||||||
# A dummy main loop:
|
# A dummy main loop:
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import zmq
|
import zmq
|
||||||
|
# from zmq.asyncio import Context, ZMQEventLoop
|
||||||
|
# import asyncio
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
|
|
||||||
class Role(Enum):
|
class Role(Enum):
|
||||||
@ -20,7 +22,7 @@ class User:
|
|||||||
self.role = role
|
self.role = role
|
||||||
|
|
||||||
class NetworkInterface:
|
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.host = host
|
||||||
self.context = context
|
self.context = context
|
||||||
self.socket = context.socket(socket_type)
|
self.socket = context.socket(socket_type)
|
||||||
@ -28,7 +30,8 @@ class NetworkInterface:
|
|||||||
|
|
||||||
#TODO: Is this right to it here?
|
#TODO: Is this right to it here?
|
||||||
self.poller.register(self.socket, zmq.POLLIN)
|
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:
|
class Property:
|
||||||
def __init__(self, property=None, replication=Replication.NONE):
|
def __init__(self, property=None, replication=Replication.NONE):
|
||||||
|
Reference in New Issue
Block a user