diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php index fd1b526a..44db5282 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php @@ -48,6 +48,7 @@ class PerformanceController extends AbstractController // Load settings from the database $options = array( 'online_timeout', + 'connection_timeout', 'updatefrequency_operator', 'updatefrequency_chat', 'max_connections_from_one_host', @@ -69,6 +70,7 @@ class PerformanceController extends AbstractController $form = $request->request; $page['formonlinetimeout'] = $form->get('onlinetimeout', $params['online_timeout']); + $page['formconnectiontimeout'] = $form->get('connectiontimeout', $params['connection_timeout']); $page['formfrequencyoperator'] = $form->get('frequencyoperator', $params['updatefrequency_operator']); $page['formfrequencychat'] = $form->get('frequencychat', $params['updatefrequency_chat']); $page['formonehostconnections'] = $form->get('onehostconnections', $params['max_connections_from_one_host']); @@ -117,6 +119,11 @@ class PerformanceController extends AbstractController $errors[] = wrong_field("Operator online time threshold"); } + $params['connection_timeout'] = $request->request->get('connectiontimeout'); + if (!is_numeric($params['connection_timeout'])) { + $errors[] = wrong_field("Connection timeout for messaging window"); + } + $params['updatefrequency_operator'] = $request->request->get('frequencyoperator'); if (!is_numeric($params['updatefrequency_operator'])) { $errors[] = wrong_field("Operator's console refresh time"); diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php index 58bac79e..b6df64ab 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php @@ -359,12 +359,12 @@ class ThreadProcessor extends ClientSideProcessor implements // Get status values if ($args['user']) { - $is_typing = abs($thread->lastPingAgent - time()) < Thread::CONNECTION_TIMEOUT + $is_typing = abs($thread->lastPingAgent - time()) < Settings::get('connection_timeout') && $thread->agentTyping; // Users can post messages only when thread is open. $can_post = $thread->state != Thread::STATE_CLOSED; } else { - $is_typing = abs($thread->lastPingUser - time()) < Thread::CONNECTION_TIMEOUT + $is_typing = abs($thread->lastPingUser - time()) < Settings::get('connection_timeout') && $thread->userTyping; // Operators can always post messages. $can_post = true; diff --git a/src/mibew/libs/classes/Mibew/Settings.php b/src/mibew/libs/classes/Mibew/Settings.php index 58302138..d5a1ffe9 100644 --- a/src/mibew/libs/classes/Mibew/Settings.php +++ b/src/mibew/libs/classes/Mibew/Settings.php @@ -101,6 +101,7 @@ class Settings 'showonlineoperators' => '0', 'enablecaptcha' => '0', 'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */ + 'connection_timeout' => 30, /* Timeout (in seconds) from the last ping when messaging window disconnects */ 'updatefrequency_operator' => 2, 'updatefrequency_chat' => 2, 'statistics_aggregation_interval' => 24 * 60 * 60, diff --git a/src/mibew/libs/classes/Mibew/Thread.php b/src/mibew/libs/classes/Mibew/Thread.php index fb3f5d3a..35e49381 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -109,11 +109,6 @@ class Thread */ const KIND_PLUGIN = 7; - /** - * Messaging window connection timeout. - */ - const CONNECTION_TIMEOUT = 30; - /** * ID of the thread. * @var int|bool @@ -558,7 +553,7 @@ class Thread } // Check if other side of the conversation have connection problems - if ($last_ping_other_side > 0 && abs(time() - $last_ping_other_side) > self::CONNECTION_TIMEOUT) { + if ($last_ping_other_side > 0 && abs(time() - $last_ping_other_side) > Settings::get('connection_timeout')) { // Connection problems detected if ($is_user) { // _Other_ side is operator @@ -577,7 +572,7 @@ class Thread $this->postMessage( self::KIND_CONN, $message_to_post, - array('created' => $last_ping_other_side + self::CONNECTION_TIMEOUT) + array('created' => $last_ping_other_side + Settings::get('connection_timeout')) ); // And update thread @@ -604,7 +599,7 @@ class Thread $this->postMessage( self::KIND_FOR_AGENT, $message_to_post, - array('created' => $last_ping_other_side + self::CONNECTION_TIMEOUT) + array('created' => $last_ping_other_side + Settings::get('connection_timeout')) ); } } diff --git a/src/mibew/styles/pages/default/templates_src/server_side/settings_performance.handlebars b/src/mibew/styles/pages/default/templates_src/server_side/settings_performance.handlebars index 8b9de464..c417565a 100644 --- a/src/mibew/styles/pages/default/templates_src/server_side/settings_performance.handlebars +++ b/src/mibew/styles/pages/default/templates_src/server_side/settings_performance.handlebars @@ -35,6 +35,15 @@
+
+ +
+ +
+ +
+
+