feat: initial work to run a dedicated server
This commit is contained in:
Submodule multi_user/libs/replication updated: f8901d458c...e380d73b03
@ -115,32 +115,34 @@ class SessionStartOperator(bpy.types.Operator):
|
||||
default_strategy=settings.right_strategy)
|
||||
|
||||
# Host a session
|
||||
if self.host:
|
||||
if self.host or runtime_settings.admin:
|
||||
# Scene setup
|
||||
if settings.start_empty:
|
||||
utils.clean_scene()
|
||||
|
||||
try:
|
||||
for scene in bpy.data.scenes:
|
||||
scene_uuid = client.add(scene)
|
||||
client.commit(scene_uuid)
|
||||
for scene in bpy.data.scenes:
|
||||
scene_uuid = client.add(scene)
|
||||
client.commit(scene_uuid)
|
||||
|
||||
pwd = runtime_settings.password if runtime_settings.password else None
|
||||
if self.host:
|
||||
try:
|
||||
client.host(
|
||||
id=settings.username,
|
||||
address=settings.ip,
|
||||
port=settings.port,
|
||||
ipc_port=settings.ipc_port,
|
||||
timeout=settings.connection_timeout
|
||||
timeout=settings.connection_timeout,
|
||||
password=pwd
|
||||
)
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, repr(e))
|
||||
logging.error(f"Error: {e}")
|
||||
finally:
|
||||
runtime_settings.is_admin = True
|
||||
|
||||
# Join a session
|
||||
else:
|
||||
utils.clean_scene()
|
||||
if pwd is None:
|
||||
utils.clean_scene()
|
||||
|
||||
try:
|
||||
client.connect(
|
||||
@ -148,13 +150,12 @@ class SessionStartOperator(bpy.types.Operator):
|
||||
address=settings.ip,
|
||||
port=settings.port,
|
||||
ipc_port=settings.ipc_port,
|
||||
timeout=settings.connection_timeout
|
||||
timeout=settings.connection_timeout,
|
||||
password=pwd
|
||||
)
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, repr(e))
|
||||
logging.error(f"Error: {e}")
|
||||
finally:
|
||||
runtime_settings.is_admin = False
|
||||
|
||||
# Background client updates service
|
||||
#TODO: Refactoring
|
||||
|
@ -340,10 +340,6 @@ class SessionUser(bpy.types.PropertyGroup):
|
||||
|
||||
|
||||
class SessionProps(bpy.types.PropertyGroup):
|
||||
is_admin: bpy.props.BoolProperty(
|
||||
name="is_admin",
|
||||
default=False
|
||||
)
|
||||
session_mode: bpy.props.EnumProperty(
|
||||
name='session_mode',
|
||||
description='session mode',
|
||||
@ -384,6 +380,16 @@ class SessionProps(bpy.types.PropertyGroup):
|
||||
description='Show only owned datablocks',
|
||||
default=True
|
||||
)
|
||||
admin: bpy.props.BoolProperty(
|
||||
name="admin",
|
||||
description='Connect as admin',
|
||||
default=False
|
||||
)
|
||||
password: bpy.props.StringProperty(
|
||||
name="password",
|
||||
description='Session password',
|
||||
subtype='PASSWORD'
|
||||
)
|
||||
user_snap_running: bpy.props.BoolProperty(
|
||||
default=False
|
||||
)
|
||||
|
@ -180,14 +180,22 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
||||
row = box.row()
|
||||
row.label(text="Timeout (ms):")
|
||||
row.prop(settings, "connection_timeout", text="")
|
||||
|
||||
row = box.row()
|
||||
if runtime_settings.session_mode == 'HOST':
|
||||
row.label(text="Password:")
|
||||
row.prop(runtime_settings, "password", text="")
|
||||
row = box.row()
|
||||
row.label(text="Start empty:")
|
||||
row.prop(settings, "start_empty", text="")
|
||||
row = box.row()
|
||||
row.operator("session.start", text="HOST").host = True
|
||||
else:
|
||||
row.prop(runtime_settings, "admin", text='Connect as admin' ,icon='DISCLOSURE_TRI_DOWN' if runtime_settings.admin
|
||||
else 'DISCLOSURE_TRI_RIGHT')
|
||||
if runtime_settings.admin:
|
||||
row = box.row()
|
||||
row.label(text="Password:")
|
||||
row.prop(runtime_settings, "password", text="")
|
||||
row = box.row()
|
||||
row.operator("session.start", text="CONNECT").host = False
|
||||
|
||||
@ -425,9 +433,8 @@ def draw_property(context, parent, property_uuid, level=0):
|
||||
|
||||
# Operations
|
||||
|
||||
have_right_to_modify = runtime_settings.is_admin or \
|
||||
item.owner == settings.username or \
|
||||
item.owner == RP_COMMON
|
||||
have_right_to_modify = item.owner == settings.username or \
|
||||
item.owner == RP_COMMON
|
||||
|
||||
if have_right_to_modify:
|
||||
detail_item_box.operator(
|
||||
|
Reference in New Issue
Block a user