fix(ui): panel pool fix
feat(client): added state report command
This commit is contained in:
15
client.py
15
client.py
@ -92,7 +92,6 @@ class RCFClient(object):
|
|||||||
self.pipe.send_multipart(
|
self.pipe.send_multipart(
|
||||||
[b"ADD", umsgpack.packb(key), (umsgpack.packb(value) if value else umsgpack.packb('None'))])
|
[b"ADD", umsgpack.packb(key), (umsgpack.packb(value) if value else umsgpack.packb('None'))])
|
||||||
|
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
"""Lookup value in distributed hash table
|
"""Lookup value in distributed hash table
|
||||||
Sends [GET][key] to the agent and waits for a value response
|
Sends [GET][key] to the agent and waits for a value response
|
||||||
@ -121,6 +120,15 @@ class RCFClient(object):
|
|||||||
else:
|
else:
|
||||||
return umsgpack.unpackb(reply[0])
|
return umsgpack.unpackb(reply[0])
|
||||||
|
|
||||||
|
def state(self):
|
||||||
|
self.pipe.send_multipart([b"STATE"])
|
||||||
|
try:
|
||||||
|
reply = self.pipe.recv_multipart()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return umsgpack.unpackb(reply[0])
|
||||||
|
|
||||||
|
|
||||||
class RCFServer(object):
|
class RCFServer(object):
|
||||||
address = None # Server address
|
address = None # Server address
|
||||||
@ -159,6 +167,7 @@ class RCFClientAgent(object):
|
|||||||
self.property_map = {}
|
self.property_map = {}
|
||||||
self.id = b"test"
|
self.id = b"test"
|
||||||
self.state = State.INITIAL
|
self.state = State.INITIAL
|
||||||
|
self.admin = False
|
||||||
self.server = None
|
self.server = None
|
||||||
self.publisher = self.ctx.socket(zmq.PUSH) # push update socket
|
self.publisher = self.ctx.socket(zmq.PUSH) # push update socket
|
||||||
self.publisher.setsockopt(zmq.IDENTITY, self.id)
|
self.publisher.setsockopt(zmq.IDENTITY, self.id)
|
||||||
@ -180,6 +189,8 @@ class RCFClientAgent(object):
|
|||||||
port = int(msg.pop(0))
|
port = int(msg.pop(0))
|
||||||
|
|
||||||
if self.server is None:
|
if self.server is None:
|
||||||
|
if address == '127.0.0.1':
|
||||||
|
self.admin = True
|
||||||
self.server = RCFServer(self.ctx, address, port, self.id)
|
self.server = RCFServer(self.ctx, address, port, self.id)
|
||||||
self.publisher.connect(
|
self.publisher.connect(
|
||||||
"tcp://{}:{}".format(address.decode(), port+2))
|
"tcp://{}:{}".format(address.decode(), port+2))
|
||||||
@ -242,6 +253,8 @@ class RCFClientAgent(object):
|
|||||||
self.pipe.send(umsgpack.packb(dump_list)
|
self.pipe.send(umsgpack.packb(dump_list)
|
||||||
if dump_list else umsgpack.packb(''))
|
if dump_list else umsgpack.packb(''))
|
||||||
|
|
||||||
|
elif command == b"STATE":
|
||||||
|
self.pipe.send(umsgpack.packb(self.state.value))
|
||||||
|
|
||||||
def rcf_client_agent(ctx, pipe, queue):
|
def rcf_client_agent(ctx, pipe, queue):
|
||||||
agent = RCFClientAgent(ctx, pipe)
|
agent = RCFClientAgent(ctx, pipe)
|
||||||
|
@ -24,6 +24,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
client_instance = None
|
client_instance = None
|
||||||
client_keys = None
|
client_keys = None
|
||||||
|
client_state = 1
|
||||||
server = None
|
server = None
|
||||||
context = None
|
context = None
|
||||||
drawer = None
|
drawer = None
|
||||||
@ -237,9 +238,11 @@ class session_refresh(bpy.types.Operator):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client_instance, client_keys
|
global client_instance, client_keys,client_state
|
||||||
|
|
||||||
client_keys = client_instance.list()
|
client_keys = client_instance.list()
|
||||||
|
client_state = client_instance.state()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@ -494,7 +497,7 @@ def depsgraph_update(scene):
|
|||||||
# if update[2] == "Master Collection":
|
# if update[2] == "Master Collection":
|
||||||
# pass
|
# pass
|
||||||
# elif update[1] in SUPPORTED_TYPES:
|
# elif update[1] in SUPPORTED_TYPES:
|
||||||
# client_instance.set("{}/{}".format(update[1], update[2]))
|
# client_instance.add("{}/{}".format(update[1], update[2]))
|
||||||
|
|
||||||
if hasattr(bpy.context, 'selected_objects'):
|
if hasattr(bpy.context, 'selected_objects'):
|
||||||
selected_objects = helpers.get_selected_objects(scene)
|
selected_objects = helpers.get_selected_objects(scene)
|
||||||
|
27
ui.py
27
ui.py
@ -60,14 +60,14 @@ class SessionSettingsPanel(bpy.types.Panel):
|
|||||||
row.operator("session.join", text="CONNECT")
|
row.operator("session.join", text="CONNECT")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
if operators.client_state == 3:
|
||||||
if operators.client_instance.agent.is_alive():
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("session.stop", icon='QUIT', text="Exit")
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
||||||
# elif operators.client.status is client.RCFStatus.CONNECTING:
|
elif operators.client_state is 2:
|
||||||
# row.label(text="connecting...")
|
row.label(text="connecting...")
|
||||||
# row = layout.row()
|
row = layout.row()
|
||||||
# row.operator("session.stop", icon='QUIT', text="CANCEL")
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
@ -82,9 +82,8 @@ class SessionUsersPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
if operators.client_instance:
|
return operators.client_state == 3
|
||||||
return operators.client_instance.agent.is_alive()
|
|
||||||
return False
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -127,10 +126,7 @@ class SessionPropertiesPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
if operators.client_instance:
|
return operators.client_state == 3
|
||||||
return operators.client_instance.agent.is_alive()
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -191,10 +187,7 @@ class SessionTaskPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
if operators.client:
|
return operators.client_state == 3
|
||||||
return operators.client.agent.is_alive()
|
|
||||||
# return operators.client.status == client.RCFStatus.CONNECTED
|
|
||||||
return False
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
Reference in New Issue
Block a user