public static function getDomain($host) { $result = Utils::resolveHost($host); if (isset($result->target) && $result->target != null) { return $result->target; } else { return $host; } }
if (substr($data, -1) == "") { $messages = explode("", $buffer . substr($data, 0, -1)); $buffer = ''; foreach ($messages as $message) { #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n"); $msg = json_decode($message); if (isset($msg)) { if ($msg->func == 'message' && $msg->body != '') { $msg = $msg->body; } elseif ($msg->func == 'unregister') { \Moxl\Stanza\Stream::end(); } elseif ($msg->func == 'register') { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $port = 5222; $dns = \Moxl\Utils::resolveHost($msg->host); if (isset($dns->target) && $dns->target != null) { $msg->host = $dns->target; } if (isset($dns->port) && $dns->port != null) { $port = $dns->port; } #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $connector->create($msg->host, $port)->then($xmpp_behaviour); } } else { return; } $rpc = new \RPC(); $rpc->handle_json($msg); $msg = \RPC::commit();