forked from GNUsocial/gnu-social
Added some more error handling and commenting
This commit is contained in:
parent
a665739283
commit
50610c2611
@ -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
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user