// Begin added for StatusNet\r
\r
private $aContactList = array();\r
+ private $aADL = array();\r
private $switchBoardSessions = array();\r
\r
/**\r
$msg_header = "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nX-MMS-IM-Format: FN=$this->font_fn; EF=$this->font_ef; CO=$this->font_co; CS=0; PF=22\r\n\r\n";\r
$msg_header_len = strlen($msg_header);\r
if ($network == 1)\r
- $maxlen = $this->max_msn_message_len - $msg_header_len;\r
+ $maxlen = $this->max_msn_message_len - $msg_header_len;\r
else\r
- $maxlen = $this->max_yahoo_message_len - $msg_header_len;\r
+ $maxlen = $this->max_yahoo_message_len - $msg_header_len;\r
$sMessage=str_replace("\r", '', $sMessage);\r
$msg=substr($sMessage,0,$maxlen);\r
return $msg_header.$msg;\r
while(!$this->connect($this->user, $this->password))\r
{\r
$this->log_message("!!! Can't connect to server: $this->error");\r
- if(!$this->NSRetryWait($this->retry_wait)) return;\r
+ $this->callHandler('ConnectFailed', NULL);\r
+ $this->NSRetryWait($this->retry_wait);\r
}\r
$this->UpdateContacts();\r
$this->LastPing=time();\r
$str = '<d n="'.$u_domain.'">';\r
$len += strlen($str);\r
if ($len > 7400) {\r
- $aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
+ $this->aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
$n++;\r
$sList = '';\r
$len = strlen($str);\r
// so we use 7475\r
if ($len > 7475) {\r
$sList .= '</d>';\r
- $aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
+ $this->aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
$n++;\r
$sList = '<d n="'.$u_domain.'">'.$str;\r
$len = strlen($sList);\r
$sList .= '</d>';\r
}\r
}\r
- $aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
+ $this->aADL[$n] = '<ml l="1">'.$sList.'</ml>';\r
// NS: >>> BLP {id} BL\r
$this->ns_writeln("BLP $this->id BL");\r
- foreach ($aADL as $str) {\r
+ foreach ($this->aADL as $str) {\r
$len = strlen($str);\r
// NS: >>> ADL {id} {size}\r
$this->ns_writeln("ADL $this->id $len");\r
public function NSreceive() {\r
$this->log_message("*** startup ***");\r
\r
- $aADL = array();\r
- \r
// Sign in again if not signed in or socket failed\r
if (!is_resource($this->NSfp) || feof($this->NSfp)) {\r
+ $this->callHandler('Reconnect', NULL);\r
$this->signon();\r
}\r
\r
$data = $this->ns_readln();\r
if($data === false) {\r
// There was no data / an error when reading from the socket so reconnect\r
+ $this->callHandler('Reconnect', NULL);\r
$this->signon();\r
} else {\r
switch (substr($data,0,3))\r
// FIXME:\r
// NS: <<< RFS ???\r
// refresh ADL, so we re-send it again\r
- if (is_array($aADL)) {\r
- foreach ($aADL as $str) {\r
+ if (is_array($this->aADL)) {\r
+ foreach ($this->aADL as $str) {\r
$len = strlen($str);\r
// NS: >>> ADL {id} {size}\r
$this->ns_writeln("ADL $this->id $len");\r
private function callHandler($event, $data) {\r
if (isset($this->myEventHandlers[$event])) {\r
call_user_func($this->myEventHandlers[$event], $data);\r
- } else {\r
- $this->noHandler($data);\r
}\r
}\r
\r
* Registers a user handler\r
* \r
* Handler List\r
- * IMIn, Pong\r
+ * IMIn, Pong, ConnectFailed, Reconnect\r
*\r
* @param String $event Event name\r
* @param String $handler User function to call\r
);
$this->conn->registerHandler("IMIn", array($this, 'handle_msn_message'));
$this->conn->registerHandler('Pong', array($this, 'update_ping_time'));
+ $this->conn->registerHandler('ConnectFailed', array($this, 'handle_connect_failed'));
+ $this->conn->registerHandler('Reconnect', array($this, 'handle_reconnect'));
$this->conn->signon();
$this->lastping = time();
}
$this->plugin->enqueue_incoming_raw($data);
return true;
}
+
+ function handle_connect_failed($data) {
+ common_log(LOG_NOTICE, 'MSN connect failed, retrying');
+ }
+
+ function handle_reconnect($data) {
+ common_log(LOG_NOTICE, 'MSN reconnecting');
+ }
function send_raw_message($data)
{