Saving working version

This commit is contained in:
Swann 2019-02-11 18:10:56 +01:00
parent 58fbdbf5bf
commit 930983b06d
No known key found for this signature in database
GPG Key ID: B02D0B41F8B6D2EE
3 changed files with 20 additions and 7 deletions

View File

@ -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()

View File

@ -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__":

View File

@ -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,