]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added error reporting to SB socket writes and call endSBSession if socket is dead...
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Wed, 16 Jun 2010 01:31:51 +0000 (02:31 +0100)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Wed, 16 Jun 2010 01:31:51 +0000 (02:31 +0100)
plugins/Msn/extlib/phpmsnclass/msn.class.php

index e38c3cc1182e90dbac0b92e699696d15cba7d741..378a3eb3ced5264b7578f44bd36ad90254989d02 100644 (file)
@@ -1455,6 +1455,7 @@ class MSN {
     private function sendMessageViaSB($to, $message) {\r
         $socket = $this->switchBoardSessionLookup[$to];\r
         if (self::socketcheck($socket)) {\r
+            $this->endSBSession($socket);\r
             return false;\r
         }\r
         \r
@@ -1467,10 +1468,10 @@ class MSN {
         $id = &$this->switchBoardSessions[$intsocket]['id'];\r
 \r
         $aMessage = $this->getMessage($Message);\r
-        //CheckEmotion...\r
+        // CheckEmotion...\r
         $MsnObjDefine=$this->GetMsnObjDefine($aMessage);\r
         if ($MsnObjDefine !== '') {\r
-            $SendString="MIME-Version: 1.0\r\nContent-Type: text/x-mms-emoticon\r\n\r\n$MsnObjDefine";\r
+            $SendString = "MIME-Version: 1.0\r\nContent-Type: text/x-mms-emoticon\r\n\r\n$MsnObjDefine";\r
             $len = strlen($SendString);\r
             // TODO handle failure during write to socket\r
             $this->sb_writeln($socket, $id, "MSG $id N $len");\r
@@ -2566,12 +2567,15 @@ X-OIM-Sequence-Num: 1
      * @param resource $socket SB socket\r
      * @param integer $id Reference to SB id\r
      * @param string $data Line to write\r
-     * @return void\r
+     * @return mixed Bytes written or false on error\r
      */\r
     private function sb_writeln($socket, &$id, $data) {\r
-        @fwrite($socket, $data."\r\n");\r
-        $this->debug_message("SB: >>> $data");\r
-        $id++;\r
+        $result = @fwrite($socket, $data."\r\n");\r
+        if ($result !== false) {\r
+            $this->debug_message("SB: >>> $data");\r
+            $id++;\r
+        }\r
+        return $result;\r
     }\r
 \r
     /**\r
@@ -2579,11 +2583,14 @@ X-OIM-Sequence-Num: 1
      * \r
      * @param resource $socket SB socket\r
      * @param $data Data to write to socket\r
-     * @return void\r
+     * @return mixed Bytes written or false on error\r
      */\r
     private function sb_writedata($socket, $data) {\r
-        @fwrite($socket, $data);\r
-        $this->debug_message("SB: >>> $data");\r
+        $result = @fwrite($socket, $data);\r
+        if ($result !== false) {\r
+            $this->debug_message("SB: >>> $data");\r
+        }\r
+        return $result;\r
     }\r
 \r
     /**\r