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(); $domain = \Moxl\Utils::getDomain($msg->host); #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $connector->create($domain, 5222)->then($xmpp_behaviour); } } else { return; } $rpc = new \RPC(); $rpc->handle_json($msg); $msg = json_encode(\RPC::commit()); \RPC::clear(); if (!empty($msg)) { echo base64_encode(gzcompress($msg, 9)) . ""; #fwrite(STDERR, colorize($msg, 'yellow')." : ".colorize('sent to the browser', 'green')."\n"); } $xml = \Moxl\API::commit(); \Moxl\API::clear(); $loop->tick(); if (!empty($xml) && $conn) { $conn->write(trim($xml)); #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); } } } else {