feat(ui refresh): Added an optionnal callback recv message function
docs(imgs): Added 2 video capture for perenity
This commit is contained in:
parent
930983b06d
commit
414cf1fc73
BIN
img/2users.mp4
Normal file
BIN
img/2users.mp4
Normal file
Binary file not shown.
BIN
img/4users.gif
Normal file
BIN
img/4users.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
@ -91,9 +91,8 @@ class Session():
|
||||
self.is_running = False
|
||||
|
||||
|
||||
|
||||
class Client():
|
||||
def __init__(self, context=zmq.Context(), id="default"):
|
||||
def __init__(self, context=zmq.Context(), id="default", recv_callback=None):
|
||||
|
||||
self.context = context
|
||||
self.pull_sock = None
|
||||
@ -101,6 +100,7 @@ class Client():
|
||||
self.poller = None
|
||||
|
||||
self.id = id
|
||||
self.recv_callback = recv_callback
|
||||
self.bind_ports()
|
||||
# Main client loop registration
|
||||
self.task = asyncio.ensure_future(self.main())
|
||||
@ -139,9 +139,14 @@ class Client():
|
||||
|
||||
if self.pull_sock in socks:
|
||||
message = self.pull_sock.recv_multipart(zmq.NOBLOCK)
|
||||
logger.info("{}:{}".format(message[0].decode('ascii'), umsgpack.unpackb(message[1])))
|
||||
logger.info("{}:{}".format(message[0].decode(
|
||||
'ascii'), umsgpack.unpackb(message[1])))
|
||||
# Store message
|
||||
self.store.append([message[0].decode('ascii'), umsgpack.unpackb(message[1])])
|
||||
self.store.append(
|
||||
[message[0].decode('ascii'), umsgpack.unpackb(message[1])])
|
||||
|
||||
if self.recv_callback:
|
||||
self.recv_callback()
|
||||
|
||||
def send_msg(self, msg):
|
||||
self.push_sock.send(umsgpack.packb(msg))
|
||||
|
@ -91,7 +91,10 @@ class close(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
# CLIENT-SERVER
|
||||
def refresh_window():
|
||||
import bpy
|
||||
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
|
||||
class session_join(bpy.types.Operator):
|
||||
bl_idname = "session.join"
|
||||
@ -106,7 +109,8 @@ class session_join(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
global client
|
||||
|
||||
client = net_components.Client()
|
||||
username = str(context.scene.session_settings.username)
|
||||
client = net_components.Client(id=username ,recv_callback=refresh_window)
|
||||
time.sleep(1)
|
||||
|
||||
bpy.ops.asyncio.loop()
|
||||
@ -150,7 +154,7 @@ class session_create(bpy.types.Operator):
|
||||
username = str(context.scene.session_settings.username)
|
||||
|
||||
server = net_components.Server()
|
||||
client = net_components.Client(id=username)
|
||||
client = net_components.Client(id=username,recv_callback=refresh_window)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user