Added callback for pong (to update time till next ping required)

This commit is contained in:
Luke Fitzgerald 2010-06-13 01:54:09 +01:00
parent 4007bce9aa
commit dc66503f33
2 changed files with 24 additions and 13 deletions

View File

@ -3524,10 +3524,12 @@ X-OIM-Sequence-Num: 1
break; break;
case 'QNG': case 'QNG':
// NS: <<< QNG {time} // 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 ($this->ping_wait == 0) $this->ping_wait = 50;
//if (is_int($use_ping) && $use_ping > 0) $ping_wait = $use_ping; //if (is_int($use_ping) && $use_ping > 0) $ping_wait = $use_ping;
//Mod by Ricky Set Online //Mod by Ricky Set Online
$this->callHandler('Pong', $ping_wait);
break; break;
case 'RNG': case 'RNG':
@ -3711,7 +3713,7 @@ X-OIM-Sequence-Num: 1
* Registers a user handler * Registers a user handler
* *
* Handler List * Handler List
* IMIn * IMIn, Pong
* *
* @param String $event Event name * @param String $event Event name
* @param String $handler User function to call * @param String $handler User function to call

View File

@ -36,7 +36,7 @@ class MsnManager extends ImManager
protected $lastping = null; protected $lastping = null;
const PING_INTERVAL = 50; private $pingInterval;
/** /**
* Initialize connection to server. * Initialize connection to server.
@ -70,7 +70,7 @@ class MsnManager extends ImManager
public function idle($timeout=0) public function idle($timeout=0)
{ {
$now = time(); $now = time();
if (empty($this->lastping) || $now - $this->lastping > self::PING_INTERVAL) { if (empty($this->lastping) || $now - $this->lastping > $pingInterval) {
$this->send_ping(); $this->send_ping();
} }
} }
@ -98,6 +98,7 @@ class MsnManager extends ImManager
) )
); );
$this->conn->registerHandler("IMIn", array($this, 'handle_msn_message')); $this->conn->registerHandler("IMIn", array($this, 'handle_msn_message'));
$this->conn->registerHandler('Pong', array($this, 'update_ping_time'));
$this->conn->signon(); $this->conn->signon();
$this->lastping = time(); $this->lastping = time();
} }
@ -117,6 +118,14 @@ class MsnManager extends ImManager
return true; 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) function handle_msn_message($data)
{ {
$this->plugin->enqueue_incoming_raw($data); $this->plugin->enqueue_incoming_raw($data);