]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Implemented error checking in sendOtherNetworkMessage
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Wed, 16 Jun 2010 01:23:19 +0000 (02:23 +0100)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Wed, 16 Jun 2010 01:23:19 +0000 (02:23 +0100)
plugins/Msn/extlib/phpmsnclass/msn.class.php

index 45d6afabb1882237c675e1d2d431bbb9727e4d6d..8049d4ca49bb83a4f9d36bbf6c896b960514aa4e 100644 (file)
@@ -1497,9 +1497,12 @@ class MSN {
     private function sendOtherNetworkMessage($to, $message, $network) {\r
         $message = $this->getMessage($message, $network);\r
         $len = strlen($message);\r
-        // TODO Introduce error checking for message sending\r
-        $this->ns_writeln("UUM $this->id $to $network 1 $len");\r
-        $this->ns_writedata($Message);\r
+        if ($this->ns_writeln("UUM $this->id $to $network 1 $len") === false) {\r
+            return false;\r
+        }\r
+        if ($this->ns_writedata($Message)) {\r
+            return false;\r
+        }\r
         $this->debug_message("*** Sent to $to (network: $network):\n$Message");\r
         return true;\r
     }\r
@@ -2497,23 +2500,29 @@ X-OIM-Sequence-Num: 1
      * Also increments id\r
      * \r
      * @param string $data Line to write to socket\r
-     * @return void\r
+     * @return mixed Bytes written or false on failure\r
      */\r
     private function ns_writeln($data) {\r
-        @fwrite($this->NSfp, $data."\r\n");\r
-        $this->debug_message("NS: >>> $data");\r
-        $this->id++;\r
+        $result = @fwrite($this->NSfp, $data."\r\n");\r
+        if ($result !== false) {\r
+            $this->debug_message("NS: >>> $data");\r
+            $this->id++;\r
+        }\r
+        return $result;\r
     }\r
 \r
     /**\r
      * Write data to NS socket\r
      * \r
      * @param string $data Data to write to socket\r
-     * @return void\r
+     * @return mixed Bytes written or false on failure\r
      */\r
     private function ns_writedata($data) {\r
-        @fwrite($this->NSfp, $data);\r
-        $this->debug_message("NS: >>> $data");\r
+        $result = @fwrite($this->NSfp, $data);\r
+        if ($result !== false) {\r
+            $this->debug_message("NS: >>> $data");\r
+        }\r
+        return $result;\r
     }\r
 \r
     /**\r