]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixed a number of bugs in the library and wrapper - Seems to work!
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Sat, 26 Jun 2010 19:55:32 +0000 (12:55 -0700)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Sat, 26 Jun 2010 19:55:32 +0000 (12:55 -0700)
plugins/Msn/extlib/phpmsnclass/msn.class.php
plugins/Msn/msnmanager.php

index 5c79b3126161414ebef8d645c00bb9c76d400c69..1c04ef7fc1263d37a53776b3ddb7cf74d040108e 100644 (file)
@@ -1309,7 +1309,7 @@ class MSN {
                     break;\r
                 }\r
                 $this->debug_message("*** MSG from $from_email: $sMsg");\r
-                $this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => $network, 'offline' => false));\r
+                $this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => 1, 'offline' => false));\r
                 break;\r
             case '217':\r
                 $this->debug_message('*** User '.$session['to'].' is offline. Trying OIM.');\r
@@ -1319,7 +1319,6 @@ class MSN {
                 if (is_numeric($code)) {\r
                     $this->error = "Error code: $code, please check the detail information from: http://msnpiki.msnfanatic.com/index.php/Reference:Error_List";\r
                     $this->debug_message("*** SB: $this->error");\r
-                    $sessionEnd=true;\r
                 }\r
                 break;\r
         }\r
@@ -1463,14 +1462,8 @@ class MSN {
         if (self::socketcheck($socket)) {\r
             return false;\r
         }\r
-        \r
-        $intsocket = (int) $socket;\r
-        if (!$this->switchBoardSessions[$intsocket]['joined']) {\r
-            // If our participant has not joined the session yet we can't message them!\r
-            return false;\r
-        }\r
 \r
-        $id = &$this->switchBoardSessions[$intsocket]['id'];\r
+        $id = &$this->switchBoardSessions[(int) $socket]['id'];\r
 \r
         $aMessage = $this->getMessage($message);\r
         // CheckEmotion...\r
@@ -1537,21 +1530,25 @@ class MSN {
                        return false;\r
                 } else {\r
                     $socket = $this->switchBoardSessionLookup[$recipient];\r
-                    if ($this->switchBoardSessions[(int) $socket]['offline']) {\r
+                    $intsocket = (int) $socket;\r
+                    if ($this->switchBoardSessions[$intsocket]['offline']) {\r
                         $this->debug_message("*** Contact ($recipient) offline, sending OIM");\r
                         $this->endSBSession($socket);\r
                         return $this->sendMessage($recipient.'@Offline', $message);\r
                     } else {\r
+                       if ($this->switchBoardSessions[$intsocket]['joined'] !== true) {\r
+                               $this->debug_message("*** Recipient has not joined session, returning false");\r
+                               return false;\r
+                       }\r
+                       \r
                         $this->debug_message("*** Attempting to send message to $recipient using existing SB session");\r
 \r
                         if ($this->sendMessageViaSB($recipient, $message)) {\r
                             $this->debug_message('*** Message sent successfully');\r
                             return true;\r
-                        } else {\r
-                            $this->debug_message('*** Message sending failed, requesting new SB session');\r
-                            $this->reqSBSession($recipient);\r
-                            return false;\r
                         }\r
+                        \r
+                        return false;\r
                     }\r
                 }\r
             } elseif ($network == 'Offline') {\r
index 933213587caeb848762c998f7026a979c3a58d8f..6fc8f1556feafceb03c6dfd36f710d30be1e2da2 100644 (file)
@@ -104,7 +104,7 @@ class MsnManager extends ImManager {
                     'debug' => true\r
                 )\r
             );\r
-            $this->conn->registerHandler("IMIn", array($this, 'handle_msn_message'));\r
+            $this->conn->registerHandler('IMin', array($this, 'handle_msn_message'));\r
             $this->conn->registerHandler('Pong', array($this, 'update_ping_time'));\r
             $this->conn->registerHandler('ConnectFailed', array($this, 'handle_connect_failed'));\r
             $this->conn->registerHandler('Reconnect', array($this, 'handle_reconnect'));\r
@@ -138,7 +138,7 @@ class MsnManager extends ImManager {
      * @param $data Time till next ping\r
      * @return void\r
      */\r
-    private function update_ping_time($data) {\r
+    public function update_ping_time($data) {\r
         $pingInterval = $data;\r
     }\r
 \r
@@ -150,7 +150,7 @@ class MsnManager extends ImManager {
     * @param array $data Data\r
     * @return boolean\r
     */\r
-    private function handle_msn_message($data) {\r
+    public function handle_msn_message($data) {\r
         $this->plugin->enqueue_incoming_raw($data);\r
         return true;\r
     }\r
@@ -161,7 +161,7 @@ class MsnManager extends ImManager {
     * @param void $data Not used (there to keep callback happy)\r
     * @return void\r
     */\r
-    private function handle_connect_failed($data) {\r
+    public function handle_connect_failed($data) {\r
         common_log(LOG_NOTICE, 'MSN connect failed, retrying');\r
     }\r
 \r
@@ -171,7 +171,7 @@ class MsnManager extends ImManager {
     * @param void $data Not used (there to keep callback happy)\r
     * @return void\r
     */\r
-    private function handle_reconnect($data) {\r
+    public function handle_reconnect($data) {\r
         common_log(LOG_NOTICE, 'MSN reconnecting');\r
     }\r
     \r
@@ -190,7 +190,7 @@ class MsnManager extends ImManager {
         if (!$this->conn->sendMessage($data['to'], $data['message'])) {\r
             return false;\r
         }\r
-\r
+        \r
         // Sending a command updates the time till next ping\r
         $this->lastping = time();\r
         $this->pingInterval = 50;\r