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