From 8175f0f3bf9fcc4c9432f9c0b78405b1e6768f9b Mon Sep 17 00:00:00 2001 From: Luke Fitzgerald Date: Sat, 26 Jun 2010 12:55:32 -0700 Subject: [PATCH] Fixed a number of bugs in the library and wrapper - Seems to work! --- plugins/Msn/extlib/phpmsnclass/msn.class.php | 25 +++++++++----------- plugins/Msn/msnmanager.php | 12 +++++----- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/plugins/Msn/extlib/phpmsnclass/msn.class.php b/plugins/Msn/extlib/phpmsnclass/msn.class.php index 5c79b31261..1c04ef7fc1 100644 --- a/plugins/Msn/extlib/phpmsnclass/msn.class.php +++ b/plugins/Msn/extlib/phpmsnclass/msn.class.php @@ -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') { diff --git a/plugins/Msn/msnmanager.php b/plugins/Msn/msnmanager.php index 933213587c..6fc8f1556f 100644 --- a/plugins/Msn/msnmanager.php +++ b/plugins/Msn/msnmanager.php @@ -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; -- 2.39.5