[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 #!/usr/bin/env php 2 <?php 3 4 $root = dirname(dirname(dirname(dirname(__FILE__)))); 5 require_once $root.'/scripts/__init_script__.php'; 6 7 $args = new PhutilArgumentParser($argv); 8 $args->setTagline('test client for Aphlict server'); 9 $args->setSynopsis(<<<EOHELP 10 **aphlict_test_client.php** [__options__] 11 Connect to the Aphlict server configured in the Phabricator config. 12 13 EOHELP 14 ); 15 $args->parseStandardArguments(); 16 $args->parse( 17 array( 18 array( 19 'name' => 'server', 20 'param' => 'uri', 21 'default' => PhabricatorEnv::getEnvConfig('notification.client-uri'), 22 'help' => 'Connect to __uri__ instead of the default server.', 23 ), 24 )); 25 $console = PhutilConsole::getConsole(); 26 27 $errno = null; 28 $errstr = null; 29 30 $uri = $args->getArg('server'); 31 $uri = new PhutilURI($uri); 32 $uri->setProtocol('tcp'); 33 34 $console->writeErr("Connecting...\n"); 35 $socket = stream_socket_client( 36 $uri, 37 $errno, 38 $errstr); 39 40 if (!$socket) { 41 $console->writeErr( 42 "Unable to connect to Aphlict (at '$uri'). Error #{$errno}: {$errstr}"); 43 exit(1); 44 } else { 45 $console->writeErr("Connected.\n"); 46 } 47 48 $io_channel = new PhutilSocketChannel($socket); 49 $proto_channel = new PhutilJSONProtocolChannel($io_channel); 50 51 $json = new PhutilJSON(); 52 while (true) { 53 $message = $proto_channel->waitForMessage(); 54 $console->writeOut($json->encodeFormatted($message)); 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |