summaryrefslogtreecommitdiff
path: root/lib/ext/Syncroton/Command/Sync.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext/Syncroton/Command/Sync.php')
-rw-r--r--lib/ext/Syncroton/Command/Sync.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/ext/Syncroton/Command/Sync.php b/lib/ext/Syncroton/Command/Sync.php
index 3a3bc26..e528999 100644
--- a/lib/ext/Syncroton/Command/Sync.php
+++ b/lib/ext/Syncroton/Command/Sync.php
@@ -123,11 +123,24 @@ class Syncroton_Command_Sync extends Syncroton_Command_Wbxml
return $this->_outputDom;
}
-
if (isset($requestXML->HeartbeatInterval)) {
+ $intervalDiv = 1;
$this->_heartbeatInterval = (int)$requestXML->HeartbeatInterval;
- } elseif (isset($requestXML->Wait)) {
- $this->_heartbeatInterval = (int)$requestXML->Wait * 60;
+ } else if (isset($requestXML->Wait)) {
+ $intervalDiv = 60;
+ $this->_heartbeatInterval = (int)$requestXML->Wait * $intervalDiv;
+ }
+
+ $maxInterval = Syncroton_Registry::getPingInterval();
+ if ($maxInterval <= 0 || $maxInterval > Syncroton_Server::MAX_HEARTBEAT_INTERVAL) {
+ $maxInterval = Syncroton_Server::MAX_HEARTBEAT_INTERVAL;
+ }
+
+ if ($this->_heartbeatInterval && $this->_heartbeatInterval > $maxInterval) {
+ $sync = $this->_outputDom->documentElement;
+ $sync->appendChild($this->_outputDom->createElementNS('uri:Sync', 'Status', self::STATUS_WAIT_INTERVAL_OUT_OF_RANGE));
+ $sync->appendChild($this->_outputDom->createElementNS('uri:Sync', 'Limit', floor($maxInterval/$intervalDiv)));
+ $this->_heartbeatInterval = null;
}
$this->_globalWindowSize = isset($requestXML->WindowSize) ? (int)$requestXML->WindowSize : 100;