From a6657392833469228522045254ba698417a15e6f Mon Sep 17 00:00:00 2001 From: Luke Fitzgerald Date: Wed, 16 Jun 2010 02:31:51 +0100 Subject: [PATCH] Added error reporting to SB socket writes and call endSBSession if socket is dead when we try to send a message --- plugins/Msn/extlib/phpmsnclass/msn.class.php | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/plugins/Msn/extlib/phpmsnclass/msn.class.php b/plugins/Msn/extlib/phpmsnclass/msn.class.php index e38c3cc118..378a3eb3ce 100644 --- a/plugins/Msn/extlib/phpmsnclass/msn.class.php +++ b/plugins/Msn/extlib/phpmsnclass/msn.class.php @@ -1455,6 +1455,7 @@ class MSN { private function sendMessageViaSB($to, $message) { $socket = $this->switchBoardSessionLookup[$to]; if (self::socketcheck($socket)) { + $this->endSBSession($socket); return false; } @@ -1467,10 +1468,10 @@ class MSN { $id = &$this->switchBoardSessions[$intsocket]['id']; $aMessage = $this->getMessage($Message); - //CheckEmotion... + // CheckEmotion... $MsnObjDefine=$this->GetMsnObjDefine($aMessage); if ($MsnObjDefine !== '') { - $SendString="MIME-Version: 1.0\r\nContent-Type: text/x-mms-emoticon\r\n\r\n$MsnObjDefine"; + $SendString = "MIME-Version: 1.0\r\nContent-Type: text/x-mms-emoticon\r\n\r\n$MsnObjDefine"; $len = strlen($SendString); // TODO handle failure during write to socket $this->sb_writeln($socket, $id, "MSG $id N $len"); @@ -2566,12 +2567,15 @@ X-OIM-Sequence-Num: 1 * @param resource $socket SB socket * @param integer $id Reference to SB id * @param string $data Line to write - * @return void + * @return mixed Bytes written or false on error */ private function sb_writeln($socket, &$id, $data) { - @fwrite($socket, $data."\r\n"); - $this->debug_message("SB: >>> $data"); - $id++; + $result = @fwrite($socket, $data."\r\n"); + if ($result !== false) { + $this->debug_message("SB: >>> $data"); + $id++; + } + return $result; } /** @@ -2579,11 +2583,14 @@ X-OIM-Sequence-Num: 1 * * @param resource $socket SB socket * @param $data Data to write to socket - * @return void + * @return mixed Bytes written or false on error */ private function sb_writedata($socket, $data) { - @fwrite($socket, $data); - $this->debug_message("SB: >>> $data"); + $result = @fwrite($socket, $data); + if ($result !== false) { + $this->debug_message("SB: >>> $data"); + } + return $result; } /** -- 2.39.5