| 9 | namespace { |
| 10 | |
| 11 | void acceptWireProtocol( |
| 12 | const std::string& host, int port, const std::string& unixPath, bool verbose |
| 13 | ) { |
| 14 | using namespace ::cucumber::internal; |
| 15 | CukeEngineImpl cukeEngine; |
| 16 | JsonWireMessageCodec wireCodec; |
| 17 | WireProtocolHandler protocolHandler(wireCodec, cukeEngine); |
| 18 | std::unique_ptr<SocketServer> server; |
| 19 | #if defined(ASIO_HAS_LOCAL_SOCKETS) |
| 20 | if (!unixPath.empty()) { |
| 21 | UnixSocketServer* const unixServer = new UnixSocketServer(&protocolHandler); |
| 22 | server.reset(unixServer); |
| 23 | unixServer->listen(unixPath); |
| 24 | if (verbose) |
| 25 | std::clog << "Listening on socket " << unixServer->listenEndpoint() << std::endl; |
| 26 | } else |
| 27 | #else |
| 28 | // Prevent warning about unused parameter |
| 29 | static_cast<void>(unixPath); |
| 30 | #endif |
| 31 | { |
| 32 | TCPSocketServer* const tcpServer = new TCPSocketServer(&protocolHandler); |
| 33 | server.reset(tcpServer); |
| 34 | tcpServer->listen(asio::ip::tcp::endpoint(asio::ip::make_address(host), port)); |
| 35 | if (verbose) |
| 36 | std::clog << "Listening on " << tcpServer->listenEndpoint() << std::endl; |
| 37 | } |
| 38 | server->acceptOnce(); |
| 39 | } |
| 40 | |
| 41 | } |
| 42 |
no test coverage detected