Fixed a number of bugs in the library and wrapper - Seems to work!

This commit is contained in:
Luke Fitzgerald 2010-06-26 12:55:32 -07:00
parent f122d0b660
commit 8175f0f3bf
2 changed files with 17 additions and 20 deletions

View File

@ -1309,7 +1309,7 @@ class MSN {
break;
}
$this->debug_message("*** MSG from $from_email: $sMsg");
$this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => $network, 'offline' => false));
$this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => 1, 'offline' => false));
break;
case '217':
$this->debug_message('*** User '.$session['to'].' is offline. Trying OIM.');
@ -1319,7 +1319,6 @@ class MSN {
if (is_numeric($code)) {
$this->error = "Error code: $code, please check the detail information from: http://msnpiki.msnfanatic.com/index.php/Reference:Error_List";
$this->debug_message("*** SB: $this->error");
$sessionEnd=true;
}
break;
}
@ -1463,14 +1462,8 @@ class MSN {
if (self::socketcheck($socket)) {
return false;
}
$intsocket = (int) $socket;
if (!$this->switchBoardSessions[$intsocket]['joined']) {
// If our participant has not joined the session yet we can't message them!
return false;
}
$id = &$this->switchBoardSessions[$intsocket]['id'];
$id = &$this->switchBoardSessions[(int) $socket]['id'];
$aMessage = $this->getMessage($message);
// CheckEmotion...
@ -1537,21 +1530,25 @@ class MSN {
return false;
} else {
$socket = $this->switchBoardSessionLookup[$recipient];
if ($this->switchBoardSessions[(int) $socket]['offline']) {
$intsocket = (int) $socket;
if ($this->switchBoardSessions[$intsocket]['offline']) {
$this->debug_message("*** Contact ($recipient) offline, sending OIM");
$this->endSBSession($socket);
return $this->sendMessage($recipient.'@Offline', $message);
} else {
if ($this->switchBoardSessions[$intsocket]['joined'] !== true) {
$this->debug_message("*** Recipient has not joined session, returning false");
return false;
}
$this->debug_message("*** Attempting to send message to $recipient using existing SB session");
if ($this->sendMessageViaSB($recipient, $message)) {
$this->debug_message('*** Message sent successfully');
return true;
} else {
$this->debug_message('*** Message sending failed, requesting new SB session');
$this->reqSBSession($recipient);
return false;
}
return false;
}
}
} elseif ($network == 'Offline') {

View File

@ -104,7 +104,7 @@ class MsnManager extends ImManager {
'debug' => true
)
);
$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->registerHandler('ConnectFailed', array($this, 'handle_connect_failed'));
$this->conn->registerHandler('Reconnect', array($this, 'handle_reconnect'));
@ -138,7 +138,7 @@ class MsnManager extends ImManager {
* @param $data Time till next ping
* @return void
*/
private function update_ping_time($data) {
public function update_ping_time($data) {
$pingInterval = $data;
}
@ -150,7 +150,7 @@ class MsnManager extends ImManager {
* @param array $data Data
* @return boolean
*/
private function handle_msn_message($data) {
public function handle_msn_message($data) {
$this->plugin->enqueue_incoming_raw($data);
return true;
}
@ -161,7 +161,7 @@ class MsnManager extends ImManager {
* @param void $data Not used (there to keep callback happy)
* @return void
*/
private function handle_connect_failed($data) {
public function handle_connect_failed($data) {
common_log(LOG_NOTICE, 'MSN connect failed, retrying');
}
@ -171,7 +171,7 @@ class MsnManager extends ImManager {
* @param void $data Not used (there to keep callback happy)
* @return void
*/
private function handle_reconnect($data) {
public function handle_reconnect($data) {
common_log(LOG_NOTICE, 'MSN reconnecting');
}
@ -190,7 +190,7 @@ class MsnManager extends ImManager {
if (!$this->conn->sendMessage($data['to'], $data['message'])) {
return false;
}
// Sending a command updates the time till next ping
$this->lastping = time();
$this->pingInterval = 50;