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
$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
* @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
* \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