This commit is contained in:
Fedor A. Fetisov 2014-12-10 18:26:55 +03:00
parent 80565efefb
commit 07c015856e
5 changed files with 22 additions and 10 deletions

View File

@ -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");

View File

@ -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;

View File

@ -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,

View File

@ -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'))
);
}
}

View File

@ -35,6 +35,15 @@
<br clear="all"/>
</div>
<div class="field">
<label for="connectiontimeout" class="flabel">{{l10n "Connection timeout for messaging window"}}</label>
<div class="fvalue">
<input id="connectiontimeout" type="text" name="connectiontimeout" size="40" value="{{formconnectiontimeout}}" class="formauth"/>
</div>
<label for="connectiontimeout" class="fdescr"> &mdash; {{l10n "Set the number of seconds after the last ping to consider the chat window still connected. Default is 30 seconds."}}</label>
<br clear="all"/>
</div>
<div class="field">
<label for="frequencyoperator" class="flabel">{{l10n "Operator's console refresh time"}}</label>
<div class="fvalue">