MCPcopy Create free account
hub / github.com/cucumber/cucumber-cpp / acceptWireProtocol

Function acceptWireProtocol

src/main.cpp:11–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace {
10
11void 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

Callers 1

CUCUMBER_CPP_EXPORT mainFunction · 0.85

Calls 4

listenMethod · 0.80
listenEndpointMethod · 0.80
acceptOnceMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected