feat: server ping timeout preferences

This commit is contained in:
Fabian 2021-07-26 17:42:13 +02:00
parent 4c1cd6b8f8
commit a49d9ee437
3 changed files with 16 additions and 5 deletions

View File

@ -1059,7 +1059,7 @@ class RefreshServerStatus(bpy.types.Operator):
settings = utils.get_preferences() settings = utils.get_preferences()
for server in settings.server_preset: for server in settings.server_preset:
infos = porcelain.request_session_info(f"{server.ip}:{server.port}", timeout=500) # TODO: timeout in a settings infos = porcelain.request_session_info(f"{server.ip}:{server.port}", timeout=settings.ping_timeout)
server.is_online = True if infos else False server.is_online = True if infos else False
if server.is_online: if server.is_online:
server.is_private = infos.get("private") server.is_private = infos.get("private")

View File

@ -247,6 +247,11 @@ class SessionPrefs(bpy.types.AddonPreferences):
description='connection timeout before disconnection', description='connection timeout before disconnection',
default=5000 default=5000
) )
ping_timeout: bpy.props.IntProperty(
name='ping timeout',
description='check if servers are online',
default=500
)
# Replication update settings # Replication update settings
depsgraph_update_rate: bpy.props.FloatProperty( depsgraph_update_rate: bpy.props.FloatProperty(
name='depsgraph update rate (s)', name='depsgraph update rate (s)',
@ -496,6 +501,9 @@ class SessionPrefs(bpy.types.AddonPreferences):
row = box.row() row = box.row()
row.label(text="Timeout (ms):") row.label(text="Timeout (ms):")
row.prop(self, "connection_timeout", text="") row.prop(self, "connection_timeout", text="")
row = box.row()
row.label(text="Server ping (ms):")
row.prop(self, "ping_timeout", text="")
# REPLICATION # REPLICATION
box = grid.box() box = grid.box()

View File

@ -131,7 +131,7 @@ class SESSION_PT_settings(bpy.types.Panel):
server_preset = settings.server_preset server_preset = settings.server_preset
selected_server = context.window_manager.server_index if context.window_manager.server_index<=len(server_preset)-1 else 0 selected_server = context.window_manager.server_index if context.window_manager.server_index<=len(server_preset)-1 else 0
active_server_name = server_preset[selected_server].name if len(server_preset)>=1 else "" active_server_name = server_preset[selected_server].name if len(server_preset)>=1 else ""
is_server_selected = True if active_server_name else False # TODO : issues when removing the lowest server in the list is_server_selected = True if active_server_name else False
# SERVER LIST # SERVER LIST
row = layout.row() row = layout.row()
@ -142,20 +142,20 @@ class SESSION_PT_settings(bpy.types.Panel):
split.label(text="Online") split.label(text="Online")
col = row.column(align=True) col = row.column(align=True)
col.operator("session.get_info", icon="FILE_REFRESH", text="") # TODO : Replace add by refresh operator col.operator("session.get_info", icon="FILE_REFRESH", text="")
row = layout.row() row = layout.row()
col = row.column(align=True) col = row.column(align=True)
col.template_list("SESSION_UL_network", "", settings, "server_preset", context.window_manager, "server_index") col.template_list("SESSION_UL_network", "", settings, "server_preset", context.window_manager, "server_index")
col.separator() col.separator()
connectOp = col.row() connectOp = col.row()
connectOp.operator("session.host", text="Host") # TODO : add a pop-up for admin and server password ? add port connectOp.operator("session.host", text="Host")
connectopcol = connectOp.column() connectopcol = connectOp.column()
connectopcol.enabled =is_server_selected connectopcol.enabled =is_server_selected
connectopcol.operator("session.connect", text="Connect") connectopcol.operator("session.connect", text="Connect")
col = row.column(align=True) col = row.column(align=True)
col.operator("session.preset_server_add", icon="ADD", text="") # TODO : add conditions (need a name, etc..) + add a checkbox for password without creating preferences col.operator("session.preset_server_add", icon="ADD", text="") # TODO : add conditions (need a name, etc..)
row_visible = col.row(align=True) row_visible = col.row(align=True)
col_visible = row_visible.column(align=True) col_visible = row_visible.column(align=True)
col_visible.enabled = is_server_selected col_visible.enabled = is_server_selected
@ -253,6 +253,9 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
net_section_row = net_section.row() net_section_row = net_section.row()
net_section_row.label(text="Timeout (ms):") net_section_row.label(text="Timeout (ms):")
net_section_row.prop(settings, "connection_timeout", text="") net_section_row.prop(settings, "connection_timeout", text="")
net_section_row = net_section.row()
net_section_row.label(text="Server ping (ms):")
net_section_row.prop(settings, "ping_timeout", text="")
#ADVANCED REPLICATION #ADVANCED REPLICATION
replication_section = layout.row().box() replication_section = layout.row().box()