forked from GNUsocial/gnu-social
Added callback for pong (to update time till next ping required)
This commit is contained in:
parent
4007bce9aa
commit
dc66503f33
@ -3524,10 +3524,12 @@ X-OIM-Sequence-Num: 1
|
||||
break;
|
||||
case 'QNG':
|
||||
// NS: <<< QNG {time}
|
||||
//@list(/* QNG */, $this->ping_wait) = @explode(' ', $data);
|
||||
@list(/* QNG */, $ping_wait) = @explode(' ', $data);
|
||||
//if ($this->ping_wait == 0) $this->ping_wait = 50;
|
||||
//if (is_int($use_ping) && $use_ping > 0) $ping_wait = $use_ping;
|
||||
//Mod by Ricky Set Online
|
||||
|
||||
$this->callHandler('Pong', $ping_wait);
|
||||
break;
|
||||
|
||||
case 'RNG':
|
||||
@ -3711,7 +3713,7 @@ X-OIM-Sequence-Num: 1
|
||||
* Registers a user handler
|
||||
*
|
||||
* Handler List
|
||||
* IMIn
|
||||
* IMIn, Pong
|
||||
*
|
||||
* @param String $event Event name
|
||||
* @param String $handler User function to call
|
||||
|
@ -36,7 +36,7 @@ class MsnManager extends ImManager
|
||||
|
||||
protected $lastping = null;
|
||||
|
||||
const PING_INTERVAL = 50;
|
||||
private $pingInterval;
|
||||
|
||||
/**
|
||||
* Initialize connection to server.
|
||||
@ -70,7 +70,7 @@ class MsnManager extends ImManager
|
||||
public function idle($timeout=0)
|
||||
{
|
||||
$now = time();
|
||||
if (empty($this->lastping) || $now - $this->lastping > self::PING_INTERVAL) {
|
||||
if (empty($this->lastping) || $now - $this->lastping > $pingInterval) {
|
||||
$this->send_ping();
|
||||
}
|
||||
}
|
||||
@ -98,6 +98,7 @@ class MsnManager extends ImManager
|
||||
)
|
||||
);
|
||||
$this->conn->registerHandler("IMIn", array($this, 'handle_msn_message'));
|
||||
$this->conn->registerHandler('Pong', array($this, 'update_ping_time'));
|
||||
$this->conn->signon();
|
||||
$this->lastping = time();
|
||||
}
|
||||
@ -117,6 +118,14 @@ class MsnManager extends ImManager
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the time till the next ping
|
||||
* @param $data Time till next ping
|
||||
*/
|
||||
function update_ping_time($data) {
|
||||
$pingInterval = $data;
|
||||
}
|
||||
|
||||
function handle_msn_message($data)
|
||||
{
|
||||
$this->plugin->enqueue_incoming_raw($data);
|
||||
|
Loading…
Reference in New Issue
Block a user