diff options
author | Luke Fitzgerald <lw.fitzgerald@googlemail.com> | 2010-06-16 14:15:08 +0100 |
---|---|---|
committer | Luke Fitzgerald <lw.fitzgerald@googlemail.com> | 2010-06-16 14:15:08 +0100 |
commit | 50610c2611b16aced92539117b9021253dc150f9 (patch) | |
tree | d011f57a8668deb5a4b8ca9f78688ebb23123a16 /plugins | |
parent | a6657392833469228522045254ba698417a15e6f (diff) |
Added some more error handling and commenting
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Msn/MsnPlugin.php | 5 | ||||
-rw-r--r-- | plugins/Msn/extlib/phpmsnclass/msn.class.php | 21 | ||||
-rw-r--r-- | plugins/Msn/msnmanager.php | 8 |
3 files changed, 24 insertions, 10 deletions
diff --git a/plugins/Msn/MsnPlugin.php b/plugins/Msn/MsnPlugin.php index f00333d72..acbc6446e 100644 --- a/plugins/Msn/MsnPlugin.php +++ b/plugins/Msn/MsnPlugin.php @@ -118,6 +118,11 @@ class MsnPlugin extends ImPlugin { }
}
+ /*
+ * Start manager on daemon start
+ *
+ * @return boolean
+ */
public function onStartImDaemonIoManagers(&$classes) {
parent::onStartImDaemonIoManagers(&$classes);
$classes[] = new MsnManager($this); // handles sending/receiving
diff --git a/plugins/Msn/extlib/phpmsnclass/msn.class.php b/plugins/Msn/extlib/phpmsnclass/msn.class.php index 378a3eb3c..3d33340b2 100644 --- a/plugins/Msn/extlib/phpmsnclass/msn.class.php +++ b/plugins/Msn/extlib/phpmsnclass/msn.class.php @@ -1455,7 +1455,6 @@ class MSN { private function sendMessageViaSB($to, $message) {
$socket = $this->switchBoardSessionLookup[$to];
if (self::socketcheck($socket)) {
- $this->endSBSession($socket);
return false;
}
@@ -1469,21 +1468,24 @@ class MSN { $aMessage = $this->getMessage($Message);
// CheckEmotion...
- $MsnObjDefine=$this->GetMsnObjDefine($aMessage);
+ $MsnObjDefine = $this->GetMsnObjDefine($aMessage);
if ($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");
- $this->sb_writedata($socket, $SendString);
+
+ if ($this->sb_writeln($socket, $id, "MSG $id N $len") === false ||
+ $this->sb_writedata($socket, $SendString) === false) {
+ return false;
+ }
}
$len = strlen($aMessage);
- // TODO handle failure during write to socket
- $this->sb_writeln($socket, $id, "MSG $id N $len");
- $this->sb_writedata($socket, $aMessage);
- // Don't close the SB session, we might as well leave it open
+ if ($this->sb_writeln($socket, $id, "MSG $id N $len") === false ||
+ $this->sb_writedata($socket, $aMessage) === false) {
+ return false;
+ }
+ // Don't close the SB session, we might as well leave it open
return true;
}
@@ -1995,7 +1997,6 @@ X-OIM-Sequence-Num: 1 $str = '<ml l="1"><d n="'.$u_domain.'"><c n="'.$u_name.'" l="'.$l.'" t="'.$network.'" /></d></ml>';
$len = strlen($str);
// NS: >>> ADL {id} {size}
- //TODO introduce error checking
$this->ns_writeln("ADL $this->id $len");
$this->ns_writedata($str);
}
diff --git a/plugins/Msn/msnmanager.php b/plugins/Msn/msnmanager.php index 66152f0d2..9826608ea 100644 --- a/plugins/Msn/msnmanager.php +++ b/plugins/Msn/msnmanager.php @@ -134,7 +134,9 @@ class MsnManager extends ImManager { /**
* Update the time till the next ping
+ *
* @param $data Time till next ping
+ * @return void
*/
private function update_ping_time($data) {
$pingInterval = $data;
@@ -173,6 +175,12 @@ class MsnManager extends ImManager { common_log(LOG_NOTICE, 'MSN reconnecting');
}
+ /**
+ * Send a message using the daemon
+ *
+ * @param $data Message
+ * @return boolean true on success
+ */
function send_raw_message($data) {
$this->connect();
if (!$this->conn) {
|