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.id = id
self.bind_ports() self.bind_ports()
# Main client loop registration # Main client loop registration
self.is_running = False
self.task = asyncio.ensure_future(self.main()) self.task = asyncio.ensure_future(self.main())
self.store = [] self.store = []
@ -128,7 +127,7 @@ class Client():
async def main(self): async def main(self):
logger.info("{} client launched".format(id)) logger.info("{} client launched".format(id))
self.is_running = True
# Prepare our context and publisher socket # Prepare our context and publisher socket
while True: while True:
# TODO: find a better way # TODO: find a better way
@ -150,7 +149,6 @@ class Client():
def stop(self): def stop(self):
logger.info("Stopping client") logger.info("Stopping client")
self.poller.unregister(self.pull_sock) self.poller.unregister(self.pull_sock)
self.is_running = False
self.push_sock.close() self.push_sock.close()
self.pull_sock.close() self.pull_sock.close()
self.task.cancel() self.task.cancel()

View File

@ -147,8 +147,10 @@ class session_create(bpy.types.Operator):
global server global server
global client global client
username = str(context.scene.session_settings.username)
server = net_components.Server() server = net_components.Server()
client = net_components.Client() client = net_components.Client(id=username)
time.sleep(1) time.sleep(1)
@ -186,11 +188,18 @@ class session_stop(bpy.types.Operator):
return {"FINISHED"} 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 = ( classes = (
session_join, session_join,
session_send, session_send,
session_stop, session_stop,
session_create, session_create,
session_settings,
) )
@ -199,11 +208,14 @@ def register():
for cls in classes: for cls in classes:
register_class(cls) register_class(cls)
bpy.types.Scene.session_settings = bpy.props.PointerProperty(type=session_settings)
def unregister(): def unregister():
from bpy.utils import unregister_class from bpy.utils import unregister_class
for cls in reversed(classes): for cls in reversed(classes):
unregister_class(cls) unregister_class(cls)
del bpy.types.Scene.session_settings
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -11,7 +11,7 @@ class SessionPanel(bpy.types.Panel):
bl_context = "scene" bl_context = "scene"
# def draw_header(self, context): # 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): def draw(self, context):
layout = self.layout layout = self.layout
@ -38,12 +38,15 @@ class SessionPanel(bpy.types.Panel):
else: else:
area_msg.label(text="Empty") area_msg.label(text="Empty")
else: else:
row = layout.row()
row.prop(scene.session_settings,"username",text="")
row = layout.row()
row.operator("session.join") row.operator("session.join")
row.operator("session.create") row.operator("session.create")
classes = ( classes = (
SessionPanel, SessionPanel,