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
@ -1573,7 +1573,7 @@ class MSN {
|
||||
// NS: >>> CHG {id} {status} {clientid} {msnobj}
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
if($this->PhotoStickerFile!==false)
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
// NS: >>> UUX {id} length
|
||||
$str = '<Data><PSM>'.htmlspecialchars($this->psm).'</PSM><CurrentMedia></CurrentMedia><MachineGuid></MachineGuid></Data>';
|
||||
$len = strlen($str);
|
||||
@ -1935,7 +1935,7 @@ class MSN {
|
||||
$this->ns_writedata($fingerprint);
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
if($this->PhotoStickerFile!==false)
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
break;
|
||||
case 'CHG':
|
||||
// NS: <<< CHG {id} {status} {code}
|
||||
@ -2012,9 +2012,9 @@ class MSN {
|
||||
|
||||
case 'RNG':
|
||||
if($this->PhotoStickerFile!==false)
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
else
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
// someone is trying to talk to us
|
||||
// NS: <<< RNG {session_id} {server} {auth_type} {ticket} {email} {alias} U {client} 0
|
||||
$this->log_message("NS: <<< RNG $data");
|
||||
@ -2022,8 +2022,8 @@ class MSN {
|
||||
@list($sb_ip, $sb_port) = @explode(':', $server);
|
||||
if($this->IsIgnoreMail($email))
|
||||
{
|
||||
$this->log_message("*** Ignore RNG from $email");
|
||||
break;
|
||||
$this->log_message("*** Ignore RNG from $email");
|
||||
break;
|
||||
}
|
||||
$this->log_message("*** RING from $email, $sb_ip:$sb_port");
|
||||
$this->addContact($email,1,$email, true);
|
||||
@ -3455,7 +3455,7 @@ X-OIM-Sequence-Num: 1
|
||||
$this->ns_writedata($fingerprint);
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
if($this->PhotoStickerFile!==false)
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
break;
|
||||
case 'CHG':
|
||||
// NS: <<< CHG {id} {status} {code}
|
||||
@ -3524,17 +3524,19 @@ 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':
|
||||
if($this->PhotoStickerFile!==false)
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));
|
||||
else
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
$this->ns_writeln("CHG $this->id NLN $this->clientid");
|
||||
// someone is trying to talk to us
|
||||
// NS: <<< RNG {session_id} {server} {auth_type} {ticket} {email} {alias} U {client} 0
|
||||
$this->log_message("NS: <<< RNG $data");
|
||||
@ -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