feat(rcf): expose connexion settings
This commit is contained in:
parent
b47e59f4c3
commit
a715e8febf
@ -12,6 +12,8 @@ import collections
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
CONNECT_TIMEOUT = 2
|
||||
WAITING_TIME = 0.001
|
||||
|
||||
class RCFFactory(object):
|
||||
"""
|
||||
@ -147,7 +149,8 @@ class Client():
|
||||
on_recv=None,
|
||||
on_post_init=None,
|
||||
is_admin=False,
|
||||
factory=None):
|
||||
factory=None,
|
||||
address="localhost"):
|
||||
|
||||
self.is_admin = is_admin
|
||||
|
||||
@ -160,8 +163,10 @@ class Client():
|
||||
self.id = id.encode()
|
||||
self.on_recv = on_recv
|
||||
self.on_post_init = on_post_init
|
||||
self.bind_ports()
|
||||
|
||||
self.address = address
|
||||
|
||||
self.bind_ports()
|
||||
# Main client loop registration
|
||||
self.task = asyncio.ensure_future(self.main())
|
||||
|
||||
@ -173,7 +178,7 @@ class Client():
|
||||
# pull socket: get update FROM server
|
||||
self.pull_sock = self.context.socket(zmq.SUB)
|
||||
self.pull_sock.linger = 0
|
||||
self.pull_sock.connect("tcp://localhost:5555")
|
||||
self.pull_sock.connect("tcp://{}:5555".format(self.address))
|
||||
self.pull_sock.setsockopt_string(zmq.SUBSCRIBE, '')
|
||||
|
||||
# request socket: send request/message over all peers throught the server
|
||||
@ -181,13 +186,13 @@ class Client():
|
||||
self.req_sock.setsockopt(zmq.IDENTITY, self.id)
|
||||
# self.req_sock.setsockopt(zmq.SNDHWM, 60)
|
||||
self.req_sock.linger = 0
|
||||
self.req_sock.connect("tcp://localhost:5556")
|
||||
self.req_sock.connect("tcp://{}:5556".format(self.address))
|
||||
|
||||
# push update socket
|
||||
self.push_sock = self.context.socket(zmq.PUSH)
|
||||
self.push_sock.setsockopt(zmq.IDENTITY, self.id)
|
||||
self.push_sock.linger = 0
|
||||
self.push_sock.connect("tcp://localhost:5557")
|
||||
self.push_sock.connect("tcp://{}:5557".format(self.address))
|
||||
self.push_sock.setsockopt(zmq.SNDHWM, 60)
|
||||
|
||||
# Sockets aggregator, not really used for now
|
||||
@ -202,6 +207,7 @@ class Client():
|
||||
# Late join mecanism
|
||||
logger.info("{} send snapshot request".format(id))
|
||||
self.req_sock.send(b"SNAPSHOT_REQUEST")
|
||||
|
||||
while True:
|
||||
try:
|
||||
rcfmsg_snapshot = RCFMessage.recv(self.req_sock)
|
||||
|
@ -291,7 +291,8 @@ class session_join(bpy.types.Operator):
|
||||
id=username,
|
||||
on_recv=recv_callbacks,
|
||||
on_post_init=post_init_callbacks,
|
||||
factory=client_factory)
|
||||
factory=client_factory,
|
||||
address=net_settings.ip)
|
||||
# time.sleep(1)
|
||||
|
||||
bpy.ops.asyncio.loop()
|
||||
@ -426,7 +427,13 @@ class session_settings(bpy.types.PropertyGroup):
|
||||
name="update_frequency", default=0.008)
|
||||
active_object = bpy.props.PointerProperty(
|
||||
name="active_object", type=bpy.types.Object)
|
||||
|
||||
session_mode= bpy.props.EnumProperty(
|
||||
name='session_mode',
|
||||
description='session mode',
|
||||
items={
|
||||
('HOST', 'hosting', 'host a session'),
|
||||
('CONNECT', 'connexion', 'connect to a session')},
|
||||
default='HOST')
|
||||
|
||||
class session_draw_clients(bpy.types.Operator):
|
||||
bl_idname = "session.draw"
|
||||
|
26
net_ui.py
26
net_ui.py
@ -13,13 +13,12 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
|
||||
def draw_header(self, context):
|
||||
pass
|
||||
# net_settings = context.scene.session_settings
|
||||
net_settings = context.scene.session_settings
|
||||
|
||||
# if net_settings.is_running:
|
||||
# self.layout.label(text="",icon='HIDE_OFF')
|
||||
# else:
|
||||
# self.layout.label(text="",icon='HIDE_ON')
|
||||
# self.layout.label(text="Offline")
|
||||
if net_settings.is_running:
|
||||
self.layout.label(text="",icon='HIDE_OFF')
|
||||
else:
|
||||
self.layout.label(text="",icon='HIDE_ON')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@ -40,10 +39,21 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
else:
|
||||
row = layout.row()
|
||||
row.prop(scene.session_settings, "username", text="username:")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("session.join")
|
||||
row.prop(scene.session_settings, "session_mode", expand=True)
|
||||
row = layout.row()
|
||||
row.operator("session.create")
|
||||
|
||||
if scene.session_settings.session_mode == 'HOST':
|
||||
row.operator("session.create",text="HOST")
|
||||
else:
|
||||
|
||||
row.prop(net_settings,"ip",text="server ip")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("session.join",text="CONNECT")
|
||||
|
||||
|
||||
|
||||
row = layout.row()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user