diff --git a/src/docs/userguide/notifications.diviner b/src/docs/userguide/notifications.diviner index f94828c541..0842cf8335 100644 --- a/src/docs/userguide/notifications.diviner +++ b/src/docs/userguide/notifications.diviner @@ -76,6 +76,10 @@ You can run `aphlict` in the foreground to get output to your console: phabricator/ $ ./bin/aphlict --foreground +You can run `support/aphlict/client/aphlict_test_client.php` to connect to the +Aphlict server from the command line. Messages the client receives will be +printed to stdout. + You can set `notification.debug` in your configuration to get additional output in your browser. diff --git a/support/aphlict/client/aphlict_test_client.php b/support/aphlict/client/aphlict_test_client.php new file mode 100755 index 0000000000..7131ef4736 --- /dev/null +++ b/support/aphlict/client/aphlict_test_client.php @@ -0,0 +1,72 @@ +#!/usr/bin/env php +setTagline('test client for Aphlict server'); +$args->setSynopsis(<<parseStandardArguments(); +$args->parse( + array( + array( + 'name' => 'server', + 'param' => 'uri', + 'default' => PhabricatorEnv::getEnvConfig('notification.client-uri'), + 'help' => 'Connect to __uri__ instead of the default server.', + ), + )); +$console = PhutilConsole::getConsole(); + +$errno = null; +$errstr = null; + +$uri = $args->getArg('server'); +$uri = new PhutilURI($uri); +$uri->setProtocol('tcp'); + +$console->writeErr("Connecting...\n"); +$socket = stream_socket_client( + $uri, + $errno, + $errstr); + +if (!$socket) { + $console->writeErr( + "Unable to connect to Aphlict (at '$uri'). Error #{$errno}: {$errstr}"); + exit(1); +} else { + $console->writeErr("Connected.\n"); +} + +$io_channel = new PhutilSocketChannel($socket); +$proto_channel = new PhutilJSONProtocolChannel($io_channel); + +$json = new PhutilJSON(); +while (true) { + $message = $proto_channel->waitForMessage(); + $console->writeOut($json->encodeFormatted($message)); +} +