feat(rcf): client status
This commit is contained in:
parent
a715e8febf
commit
67122c6fcd
@ -8,6 +8,7 @@ import time
|
||||
import random
|
||||
import struct
|
||||
import collections
|
||||
from enum import Enum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
@ -15,6 +16,11 @@ logging.basicConfig(level=logging.DEBUG)
|
||||
CONNECT_TIMEOUT = 2
|
||||
WAITING_TIME = 0.001
|
||||
|
||||
class RCFStatus(Enum):
|
||||
IDLE = 1
|
||||
CONNECTING = 2
|
||||
CONNECTED = 3
|
||||
|
||||
class RCFFactory(object):
|
||||
"""
|
||||
Abstract layer used to bridge external and inter
|
||||
@ -152,6 +158,7 @@ class Client():
|
||||
factory=None,
|
||||
address="localhost"):
|
||||
|
||||
self.status = RCFStatus.IDLE
|
||||
self.is_admin = is_admin
|
||||
|
||||
# 0MQ vars
|
||||
@ -202,6 +209,7 @@ class Client():
|
||||
time.sleep(0.1)
|
||||
|
||||
async def main(self):
|
||||
self.status = RCFStatus.CONNECTING
|
||||
logger.info("{} client syncing".format(id))
|
||||
|
||||
# Late join mecanism
|
||||
@ -230,7 +238,7 @@ class Client():
|
||||
self.push_update("net/objects/{}".format(self.id.decode()),"client_object",None)
|
||||
|
||||
|
||||
|
||||
self.status = RCFStatus.CONNECTED
|
||||
# Main loop
|
||||
while True:
|
||||
# TODO: find a better way
|
||||
@ -348,3 +356,5 @@ class Server():
|
||||
self.request_sock.close()
|
||||
self.collector_sock.close()
|
||||
self.task.cancel()
|
||||
|
||||
self.status= RCFStatus.IDLE
|
||||
|
41
net_ui.py
41
net_ui.py
@ -13,12 +13,12 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
|
||||
def draw_header(self, context):
|
||||
pass
|
||||
net_settings = context.scene.session_settings
|
||||
# net_settings = context.scene.session_settings
|
||||
|
||||
if net_settings.is_running:
|
||||
self.layout.label(text="",icon='HIDE_OFF')
|
||||
else:
|
||||
self.layout.label(text="",icon='HIDE_ON')
|
||||
# if net_settings.is_running:
|
||||
# self.layout.label(text="",icon='HIDE_OFF')
|
||||
# else:
|
||||
# self.layout.label(text="",icon='HIDE_ON')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@ -28,15 +28,7 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
# Create a simple row.
|
||||
row = layout.row()
|
||||
|
||||
if net_operators.client:
|
||||
row.label(text="Net frequency:")
|
||||
row.prop(net_settings, "update_frequency", text="")
|
||||
row = layout.row()
|
||||
|
||||
row = layout.row()
|
||||
row.operator("session.stop", icon='QUIT', text="Exit")
|
||||
|
||||
else:
|
||||
if net_operators.client is None:
|
||||
row = layout.row()
|
||||
row.prop(scene.session_settings, "username", text="username:")
|
||||
|
||||
@ -53,6 +45,19 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.operator("session.join",text="CONNECT")
|
||||
|
||||
else:
|
||||
|
||||
if net_operators.client.status is net_components.RCFStatus.CONNECTED:
|
||||
row.label(text="Net frequency:")
|
||||
row.prop(net_settings, "update_frequency", text="")
|
||||
row = layout.row()
|
||||
row.operator("session.stop", icon='QUIT', text="Exit")
|
||||
elif net_operators.client.status is net_components.RCFStatus.CONNECTING:
|
||||
row.label(text="connecting...")
|
||||
row = layout.row()
|
||||
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||
|
||||
|
||||
|
||||
|
||||
row = layout.row()
|
||||
@ -68,7 +73,9 @@ class SessionUsersPanel(bpy.types.Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return net_operators.client
|
||||
if net_operators.client:
|
||||
return net_operators.client.status == net_components.RCFStatus.CONNECTED
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@ -112,7 +119,9 @@ class SessionPropertiesPanel(bpy.types.Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return net_operators.client
|
||||
if net_operators.client:
|
||||
return net_operators.client.status == net_components.RCFStatus.CONNECTED
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
Loading…
x
Reference in New Issue
Block a user