// NS: >>> CHG {id} {status} {clientid} {msnobj}\r
$this->ns_writeln("CHG $this->id NLN $this->clientid"); \r
if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
// NS: >>> UUX {id} length\r
$str = '<Data><PSM>'.htmlspecialchars($this->psm).'</PSM><CurrentMedia></CurrentMedia><MachineGuid></MachineGuid></Data>';\r
$len = strlen($str);\r
$this->ns_writedata($fingerprint);\r
$this->ns_writeln("CHG $this->id NLN $this->clientid"); \r
if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
break;\r
case 'CHG':\r
// NS: <<< CHG {id} {status} {code}\r
\r
case 'RNG':\r
if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
else\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid");\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid");\r
// someone is trying to talk to us\r
// NS: <<< RNG {session_id} {server} {auth_type} {ticket} {email} {alias} U {client} 0\r
$this->log_message("NS: <<< RNG $data");\r
@list($sb_ip, $sb_port) = @explode(':', $server);\r
if($this->IsIgnoreMail($email)) \r
{\r
- $this->log_message("*** Ignore RNG from $email");\r
- break; \r
+ $this->log_message("*** Ignore RNG from $email");\r
+ break;\r
}\r
$this->log_message("*** RING from $email, $sb_ip:$sb_port");\r
$this->addContact($email,1,$email, true);\r
$this->ns_writedata($fingerprint);\r
$this->ns_writeln("CHG $this->id NLN $this->clientid"); \r
if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
break;\r
case 'CHG':\r
// NS: <<< CHG {id} {status} {code}\r
break;\r
case 'QNG':\r
// NS: <<< QNG {time}\r
- //@list(/* QNG */, $this->ping_wait) = @explode(' ', $data);\r
+ @list(/* QNG */, $ping_wait) = @explode(' ', $data);\r
//if ($this->ping_wait == 0) $this->ping_wait = 50;\r
//if (is_int($use_ping) && $use_ping > 0) $ping_wait = $use_ping;\r
//Mod by Ricky Set Online\r
+ \r
+ $this->callHandler('Pong', $ping_wait);\r
break;\r
\r
case 'RNG':\r
if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
else\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid");\r
+ $this->ns_writeln("CHG $this->id NLN $this->clientid");\r
// someone is trying to talk to us\r
// NS: <<< RNG {session_id} {server} {auth_type} {ticket} {email} {alias} U {client} 0\r
$this->log_message("NS: <<< RNG $data");\r
* Registers a user handler\r
* \r
* Handler List\r
- * IMIn\r
+ * IMIn, Pong\r
*\r
* @param String $event Event name\r
* @param String $handler User function to call\r
protected $lastping = null;
- const PING_INTERVAL = 50;
+ private $pingInterval;
/**
* Initialize connection to server.
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();
}
}
)
);
$this->conn->registerHandler("IMIn", array($this, 'handle_msn_message'));
+ $this->conn->registerHandler('Pong', array($this, 'update_ping_time'));
$this->conn->signon();
$this->lastping = time();
}
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);