Added error reporting to SB socket writes and call endSBSession if socket is dead when we try to send a message

This commit is contained in:
Luke Fitzgerald 2010-06-16 02:31:51 +01:00
parent 6f388a8b50
commit a665739283

View File

@ -1455,6 +1455,7 @@ class MSN {
private function sendMessageViaSB($to, $message) { private function sendMessageViaSB($to, $message) {
$socket = $this->switchBoardSessionLookup[$to]; $socket = $this->switchBoardSessionLookup[$to];
if (self::socketcheck($socket)) { if (self::socketcheck($socket)) {
$this->endSBSession($socket);
return false; return false;
} }
@ -2566,25 +2567,31 @@ X-OIM-Sequence-Num: 1
* @param resource $socket SB socket * @param resource $socket SB socket
* @param integer $id Reference to SB id * @param integer $id Reference to SB id
* @param string $data Line to write * @param string $data Line to write
* @return void * @return mixed Bytes written or false on error
*/ */
private function sb_writeln($socket, &$id, $data) { private function sb_writeln($socket, &$id, $data) {
@fwrite($socket, $data."\r\n"); $result = @fwrite($socket, $data."\r\n");
if ($result !== false) {
$this->debug_message("SB: >>> $data"); $this->debug_message("SB: >>> $data");
$id++; $id++;
} }
return $result;
}
/** /**
* Write data to given SB socket * Write data to given SB socket
* *
* @param resource $socket SB socket * @param resource $socket SB socket
* @param $data Data to write to socket * @param $data Data to write to socket
* @return void * @return mixed Bytes written or false on error
*/ */
private function sb_writedata($socket, $data) { private function sb_writedata($socket, $data) {
@fwrite($socket, $data); $result = @fwrite($socket, $data);
if ($result !== false) {
$this->debug_message("SB: >>> $data"); $this->debug_message("SB: >>> $data");
} }
return $result;
}
/** /**
* Get all the sockets currently in use * Get all the sockets currently in use