Added better error handling to signon method
This commit is contained in:
parent
3d6bb5a597
commit
d1c9908282
|
@ -139,6 +139,7 @@ class MSN {
|
||||||
}
|
}
|
||||||
$this->debug = isset($Configs['debug']) ? $Configs['debug'] : false;
|
$this->debug = isset($Configs['debug']) ? $Configs['debug'] : false;
|
||||||
$this->timeout = $timeout;
|
$this->timeout = $timeout;
|
||||||
|
|
||||||
// check support
|
// check support
|
||||||
if (!function_exists('curl_init')) throw new Exception("We need curl module!\n");
|
if (!function_exists('curl_init')) throw new Exception("We need curl module!\n");
|
||||||
if (!function_exists('preg_match')) throw new Exception("We need pcre module!\n");
|
if (!function_exists('preg_match')) throw new Exception("We need pcre module!\n");
|
||||||
|
@ -1089,21 +1090,22 @@ class MSN {
|
||||||
*/
|
*/
|
||||||
public function signon() {
|
public function signon() {
|
||||||
$this->log_message("*** try to connect to MSN network");
|
$this->log_message("*** try to connect to MSN network");
|
||||||
|
|
||||||
|
while(true) {
|
||||||
while(!$this->connect($this->user, $this->password))
|
while(!$this->connect($this->user, $this->password))
|
||||||
{
|
{
|
||||||
$this->signonFailed("!!! Can't connect to server: $this->error");
|
$this->signonFailure("!!! Can't connect to server: $this->error");
|
||||||
}
|
}
|
||||||
if(!$this->UpdateContacts()) {
|
if($this->UpdateContacts() === false) {
|
||||||
$this->signonFailed('!!! Could not update contacts');
|
$this->signonFailure('!!! Update Contacts failed');
|
||||||
return $this->signon();
|
continue;
|
||||||
}
|
}
|
||||||
$this->LastPing=time();
|
$this->LastPing=time();
|
||||||
$this->log_message("*** connected, wait for command");
|
$this->log_message("*** connected, wait for command");
|
||||||
$start_tm = time();
|
$start_tm = time();
|
||||||
$ping_tm = time();
|
$ping_tm = time();
|
||||||
if(($this->aContactList = $this->getMembershipList()) === false) {
|
if(($this->aContactList = $this->getMembershipList()) === false) {
|
||||||
$this->signonFailed('!!! Could not get Membership List');
|
continue;
|
||||||
return $this->signon();
|
|
||||||
}
|
}
|
||||||
if ($this->update_pending) {
|
if ($this->update_pending) {
|
||||||
if (is_array($this->aContactList)) {
|
if (is_array($this->aContactList)) {
|
||||||
|
@ -1203,9 +1205,16 @@ class MSN {
|
||||||
$len = strlen($str);
|
$len = strlen($str);
|
||||||
$this->ns_writeln("UUX $this->id $len");
|
$this->ns_writeln("UUX $this->id $len");
|
||||||
$this->ns_writedata($str);
|
$this->ns_writedata($str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function signonFailed($message) {
|
/**
|
||||||
|
* Called if there is an error during signon
|
||||||
|
*
|
||||||
|
* @param $message Error message to log
|
||||||
|
*/
|
||||||
|
private function signonFailure($message) {
|
||||||
$this->log_message($message);
|
$this->log_message($message);
|
||||||
$this->callHandler('ConnectFailed', NULL);
|
$this->callHandler('ConnectFailed', NULL);
|
||||||
$this->NSRetryWait($this->retry_wait);
|
$this->NSRetryWait($this->retry_wait);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user