added basic schema
This commit is contained in:
parent
afd30708f3
commit
fa9c594cce
@ -1,5 +1,9 @@
|
|||||||
# Realtime Collaborative Framework experiments
|
# Realtime Collaborative Framework experiments
|
||||||
|
|
||||||
|
## Idea
|
||||||
|
|
||||||
|
![basic](img/basic.png)
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
| Dependency | Version | Needed |
|
| Dependency | Version | Needed |
|
||||||
|
BIN
img/basic.png
Normal file
BIN
img/basic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
1134
libs/umsgpack.py
Normal file
1134
libs/umsgpack.py
Normal file
File diff suppressed because it is too large
Load Diff
80
main.py
80
main.py
@ -5,50 +5,58 @@ import zmq
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
|
from zmq.asyncio import Context, ZMQEventLoop
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
Url = 'tcp://127.0.0.1:5555'
|
||||||
|
Ctx = Context()
|
||||||
|
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def server():
|
||||||
|
print("Getting ready for hello world client. Ctrl-C to exit.\n")
|
||||||
|
socket = Ctx.socket(zmq.REP)
|
||||||
|
socket.bind(Url)
|
||||||
|
while True:
|
||||||
|
# Wait for next request from client
|
||||||
|
message = yield from socket.recv()
|
||||||
|
print("Received request: {}".format(message))
|
||||||
|
# Do some "work"
|
||||||
|
yield from asyncio.sleep(1)
|
||||||
|
# Send reply back to client
|
||||||
|
message = message.decode('utf-8')
|
||||||
|
message = '{}, world'.format(message)
|
||||||
|
message = message.encode('utf-8')
|
||||||
|
print("Sending reply: {}".format(message))
|
||||||
|
yield from socket.send(message)
|
||||||
|
|
||||||
|
|
||||||
# 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
|
args = sys.argv[1:]
|
||||||
parser = argparse.ArgumentParser(
|
if len(args) != 0:
|
||||||
description='Launch an instance of collaboration system')
|
sys.exit(__doc__)
|
||||||
parser.add_argument('-r', choices=list(net_components.Role),
|
|
||||||
type=net_components.Role, help='role for the instance ')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
instance_role = args.r
|
|
||||||
instance_context = zmq.Context()
|
|
||||||
|
|
||||||
print("Starting a {} instance \n".format(instance_role))
|
|
||||||
|
|
||||||
# Create a World instance to hold everything:
|
|
||||||
world = esper.World()
|
|
||||||
|
|
||||||
# Instantiate a Processor (or more), and add them to the world:
|
|
||||||
network_system = net_systems.NetworkSystem()
|
|
||||||
world.add_processor(network_system)
|
|
||||||
|
|
||||||
# Instanciate a session entity
|
|
||||||
session = world.create_entity()
|
|
||||||
|
|
||||||
world.add_component(
|
|
||||||
session, net_components.NetworkInterface(context=instance_context))
|
|
||||||
world.add_component(
|
|
||||||
session, net_components.User(role=instance_role))
|
|
||||||
|
|
||||||
|
|
||||||
# A dummy main loop:
|
|
||||||
try:
|
try:
|
||||||
while True:
|
loop = asyncio.get_event_loop()
|
||||||
# Call world.process() to run all Processors.
|
loop.run_until_complete(server())
|
||||||
world.process()
|
|
||||||
time.sleep(1)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
return
|
print('\nFinished (interrupted)')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Socket to talk to server
|
||||||
|
print("Connecting to hello world server...")
|
||||||
|
socket = context.socket(zmq.REQ)
|
||||||
|
socket.connect("tcp://localhost:5555")
|
||||||
|
|
||||||
|
# Do 10 requests, waiting each time for a response
|
||||||
|
for request in range(10):
|
||||||
|
print("Sending request %s ..." % request)
|
||||||
|
socket.send(b"Hello")
|
||||||
|
|
||||||
|
# Get the reply.
|
||||||
|
message = socket.recv()
|
||||||
|
print("Received reply %s [ %s ]" % (request, message))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
52
main_old.py
Normal file
52
main_old.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import net_systems
|
||||||
|
import net_components
|
||||||
|
from libs.esper import esper
|
||||||
|
import zmq
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
|
||||||
|
# TODO: Implement a manager class for each aspect (ex: Network_Manager)
|
||||||
|
# TODO: Is it right to implement server-client as ESC ?...
|
||||||
|
def main():
|
||||||
|
# Argument parsing
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Launch an instance of collaboration system')
|
||||||
|
parser.add_argument('-r', choices=list(net_components.Role),
|
||||||
|
type=net_components.Role, help='role for the instance ')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
instance_role = args.r
|
||||||
|
instance_context = zmq.Context()
|
||||||
|
|
||||||
|
print("Starting a {} instance \n".format(instance_role))
|
||||||
|
|
||||||
|
# Create a World instance to hold everything:
|
||||||
|
world = esper.World()
|
||||||
|
|
||||||
|
# Instantiate a Processor (or more), and add them to the world:
|
||||||
|
network_system = net_systems.NetworkSystem()
|
||||||
|
world.add_processor(network_system)
|
||||||
|
|
||||||
|
# Instanciate a session entity
|
||||||
|
session = world.create_entity()
|
||||||
|
|
||||||
|
world.add_component(
|
||||||
|
session, net_components.NetworkInterface(context=instance_context))
|
||||||
|
world.add_component(
|
||||||
|
session, net_components.User(role=instance_role))
|
||||||
|
|
||||||
|
|
||||||
|
# A dummy main loop:
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
# Call world.process() to run all Processors.
|
||||||
|
world.process()
|
||||||
|
time.sleep(1)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
23
msgpacktest.py
Normal file
23
msgpacktest.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
thirdPartyDir = "C:\\Users\\slumber\\repos\\phd\src\\2019_rcf\\libs"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if thirdPartyDir in sys.path:
|
||||||
|
print('Third party module already added')
|
||||||
|
else:
|
||||||
|
print('Adding local modules dir to the path')
|
||||||
|
sys.path.insert(0, thirdPartyDir)
|
||||||
|
|
||||||
|
|
||||||
|
import umsgpack
|
||||||
|
import bpy
|
||||||
|
import esper
|
||||||
|
|
||||||
|
|
||||||
|
#c = umsgpack.packb("test")
|
||||||
|
#print(umsgpack.unpackb(c))
|
||||||
|
|
@ -42,3 +42,4 @@ class Function:
|
|||||||
def __init__(self, function=None):
|
def __init__(self, function=None):
|
||||||
self.function = function
|
self.function = function
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user