diff --git a/net_components.py b/net_components.py index 4c708b4..b67b66b 100644 --- a/net_components.py +++ b/net_components.py @@ -103,7 +103,6 @@ class Client(): self.id = id self.bind_ports() # Main client loop registration - self.is_running = False self.task = asyncio.ensure_future(self.main()) self.store = [] @@ -128,7 +127,7 @@ class Client(): async def main(self): logger.info("{} client launched".format(id)) - self.is_running = True + # Prepare our context and publisher socket while True: # TODO: find a better way @@ -150,7 +149,6 @@ class Client(): def stop(self): logger.info("Stopping client") self.poller.unregister(self.pull_sock) - self.is_running = False self.push_sock.close() self.pull_sock.close() self.task.cancel() diff --git a/net_operators.py b/net_operators.py index 67fa964..c9d2708 100644 --- a/net_operators.py +++ b/net_operators.py @@ -147,8 +147,10 @@ class session_create(bpy.types.Operator): global server global client + username = str(context.scene.session_settings.username) + server = net_components.Server() - client = net_components.Client() + client = net_components.Client(id=username) time.sleep(1) @@ -186,11 +188,18 @@ class session_stop(bpy.types.Operator): return {"FINISHED"} +class session_settings(bpy.types.PropertyGroup): + username = bpy.props.StringProperty(name="Username",default="DefaultUser") + ip = bpy.props.StringProperty(name="localhost") + port = bpy.props.IntProperty(name="5555") + +# TODO: Rename to match official convention classes = ( session_join, session_send, session_stop, session_create, + session_settings, ) @@ -199,11 +208,14 @@ def register(): for cls in classes: register_class(cls) + bpy.types.Scene.session_settings = bpy.props.PointerProperty(type=session_settings) -def unregister(): +def unregister(): from bpy.utils import unregister_class for cls in reversed(classes): unregister_class(cls) + + del bpy.types.Scene.session_settings if __name__ == "__main__": diff --git a/net_ui.py b/net_ui.py index f89784c..e128451 100644 --- a/net_ui.py +++ b/net_ui.py @@ -11,7 +11,7 @@ class SessionPanel(bpy.types.Panel): bl_context = "scene" # def draw_header(self, context): - # self.layout.prop(context.scene, "use_gravity", text="") + # self.layout.prop(context.scene.session_settings, "username", text="") def draw(self, context): layout = self.layout @@ -38,12 +38,15 @@ class SessionPanel(bpy.types.Panel): else: area_msg.label(text="Empty") else: + row = layout.row() + row.prop(scene.session_settings,"username",text="") + row = layout.row() row.operator("session.join") row.operator("session.create") - + classes = ( SessionPanel,