}\r
\r
$this->debug_message("NS: <<< XFR SB");\r
- $user = array_shift($this->waitingForXFR);\r
- $bSBresult = $this->switchboard_control($ip, $port, $cki_code, $User, $Message);\r
- /*\r
- $bSBresult = $this->switchboard_control($ip, $port, $cki_code, $aMSNUsers[$nCurrentUser], $sMessage);\r
- if ($bSBresult === false) {\r
- // error for switchboard\r
- $this->debug_message("!!! error for sending message to ".$aMSNUsers[$nCurrentUser]);\r
- $aOfflineUsers[] = $aMSNUsers[$nCurrentUser];\r
- }*/\r
+ $session = array_shift($this->waitingForXFR);\r
+ $this->connectToSBSession('Active', $ip, $port, $session['to'], array('cki' => $cki_code));\r
break;\r
case 'QNG':\r
// NS: <<< QNG {time}\r
// we don't need the data, just ignore it\r
// request user to join this switchboard\r
// SB: >>> CAL {id} {user}\r
- $this->sb_writeln($socket, $id, "CAL $this->id $user");\r
+ $this->sb_writeln($socket, $id, "CAL $id ".$session['to']);\r
break;\r
case 'CAL':\r
// SB: <<< CAL {id} RINGING {?}\r
$footer = pack("L", 0);\r
$message = "MIME-Version: 1.0\r\nContent-Type: application/x-msnmsgrp2p\r\nP2P-Dest: $from_email\r\n\r\n$hdr$footer";\r
$len = strlen($message);\r
- $this->sb_writeln($socket, $id, "MSG $this->id D $len");\r
+ $this->sb_writeln($socket, $id, "MSG $id D $len");\r
$this->sb_writedata($socket, $message);\r
$this->debug_message("*** p2p: send display picture acknowledgement for $hdr_SessionID");\r
$this->debug_message("*** p2p: Invite ACK message:\n".$this->dump_binary($message));\r
"MIME-Version: 1.0\r\n".\r
"Content-Type: application/x-msnmsgrp2p\r\n".\r
"P2P-Dest: $from_email\r\n\r\n$hdr$MessagePayload$footer";\r
- $this->sb_writeln($socket, $id, "MSG $this->id D ".strlen($message));\r
+ $this->sb_writeln($socket, $id, "MSG $id D ".strlen($message));\r
$this->sb_writedata($socket, $message);\r
$this->debug_message("*** p2p: dump 200 ok message:\n".$this->dump_binary($message));\r
$this->sb_readln($socket); // Read ACK;\r
"MIME-Version: 1.0\r\n".\r
"Content-Type: application/x-msnmsgrp2p\r\n".\r
"P2P-Dest: $from_email\r\n\r\n$hdr".pack('L', 0)."$footer";\r
- $this->sb_writeln($socket, $id, "MSG $this->id D ".strlen($message));\r
+ $this->sb_writeln($socket, $id, "MSG $id D ".strlen($message));\r
$this->sb_writedata($socket, $message);\r
$this->debug_message("*** p2p: dump send Data preparation message:\n".$this->dump_binary($message));\r
$this->debug_message("*** p2p: Data Prepare Hdr:\n".$this->dump_binary($hdr));\r
"MIME-Version: 1.0\r\n".\r
"Content-Type: application/x-msnmsgrp2p\r\n".\r
"P2P-Dest: $from_email\r\n\r\n$hdr$FileContent$footer";\r
- $this->sb_writeln($socket, $id, "MSG $this->id D ".strlen($message));\r
+ $this->sb_writeln($socket, $id, "MSG $id D ".strlen($message));\r
$this->sb_writedata($socket, $message);\r
$this->debug_message("*** p2p: dump send Data Content message $Offset / $FileSize :\n".$this->dump_binary($message));\r
$this->debug_message("*** p2p: Data Content Hdr:\n".$this->dump_binary($hdr));\r
$this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => $network, 'offline' => false));\r
break;\r
case '217':\r
- $this->debug_message("*** User $user is offline. Trying OIM.");\r
+ $this->debug_message('*** User '.$session['to'].' is offline. Trying OIM.');\r
$session['offline'] = true;\r
break;\r
default:\r
'offline' => false,\r
'XFRReqTime' => time()\r
);\r
- $this->waitingForXFR[] = &$this->switchBoardSessions[$to];\r
+ $this->waitingForXFR[$to] = &$this->switchBoardSessions[$to];\r
}\r
\r
/**\r
'offline' => false,\r
'XFRReqTime' => time()\r
);\r
-\r
+ \r
// Change the index of the session to the socket\r
$intsocket = (int) $socket;\r
$this->switchBoardSessions[$intsocket] = $this->switchBoardSessions[$to];\r
unset($this->switchBoardSessions[$to]);\r
-\r
+ \r
$id = &$this->switchBoardSessions[$intsocket]['id'];\r
\r
if ($mode == 'Active') {\r
\r
$id = &$this->switchBoardSessions[$intsocket]['id'];\r
\r
- $aMessage = $this->getMessage($Message);\r
+ $aMessage = $this->getMessage($message);\r
// CheckEmotion...\r
$MsnObjDefine = $this->GetMsnObjDefine($aMessage);\r
if ($MsnObjDefine !== '') {\r
\r
if ($this->sb_writeln($socket, $id, "MSG $id N $len") === false ||\r
$this->sb_writedata($socket, $aMessage) === false) {\r
- return false;\r
+ return false;\r
}\r
\r
// Don't close the SB session, we might as well leave it open\r
if ($message != '') {\r
list($name, $host, $network) = explode('@', $to);\r
$network = $network == '' ? 1 : $network;\r
- $recipient = $name.$host;\r
+ $recipient = $name.'@'.$host;\r
\r
if ($network === 1) {\r
- if (!isset($this->switchBoardSessionLookup[$recipient]) && (!isset($this->switchBoardSessions[$recipient])\r
- || time() - $this->switchBoardSessions[$recipient]['XFRReqTime'] > $this->XFRReqTimeout)) {\r
- $this->debug_message("*** No existing SB session or request has timed out");\r
- $this->reqSBSession($recipient);\r
- return false;\r
+ if (!isset($this->switchBoardSessionLookup[$recipient])) {\r
+ if (!isset($this->switchBoardSessions[$recipient]) || time() - $this->switchBoardSessions[$recipient]['XFRReqTime'] > $this->XFRReqTimeout) {\r
+ $this->debug_message("*** No existing SB session or request has timed out");\r
+ $this->reqSBSession($recipient);\r
+ }\r
+ return false;\r
} else {\r
- $socket = $this->switchBoardSessionLookup[$to];\r
+ $socket = $this->switchBoardSessionLookup[$recipient];\r
if ($this->switchBoardSessions[(int) $socket]['offline']) {\r
$this->debug_message("*** Contact ($recipient) offline, sending OIM");\r
$this->endSBSession($socket);\r
return true;\r
} else {\r
$this->debug_message('*** Message sending failed, requesting new SB session');\r
- $this->reqSBSession($to);\r
+ $this->reqSBSession($recipient);\r
return false;\r
}\r
}\r