Commit eab43f35 by Ben Clayton

net::Server: Fix onError parameter default.

The onError parameter of Server::start was default initialized with OnError(), which is an 'invalid target', not a no-op implementation. Replace with a true no-op implementation.
parent cc7b68a3
......@@ -28,6 +28,9 @@ std::shared_ptr<ReaderWriter> connect(const char* addr, int port);
// Server implements a basic TCP server.
class Server {
// IgnoreErrors matches the OnError signature, and does nothing.
static inline void IgnoreErrors(const char*) {}
public:
using OnError = std::function<void(const char*)>;
using OnConnect = std::function<void(const std::shared_ptr<ReaderWriter>&)>;
......@@ -42,7 +45,7 @@ class Server {
// onError will be called for any connection errors.
virtual bool start(int port,
const OnConnect& callback,
const OnError& onError = OnError()) = 0;
const OnError& onError = IgnoreErrors) = 0;
// stop() stops listening for connections.
// stop() is implicitly called on destruction.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment