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); ...@@ -28,6 +28,9 @@ std::shared_ptr<ReaderWriter> connect(const char* addr, int port);
// Server implements a basic TCP server. // Server implements a basic TCP server.
class Server { class Server {
// IgnoreErrors matches the OnError signature, and does nothing.
static inline void IgnoreErrors(const char*) {}
public: public:
using OnError = std::function<void(const char*)>; using OnError = std::function<void(const char*)>;
using OnConnect = std::function<void(const std::shared_ptr<ReaderWriter>&)>; using OnConnect = std::function<void(const std::shared_ptr<ReaderWriter>&)>;
...@@ -42,7 +45,7 @@ class Server { ...@@ -42,7 +45,7 @@ class Server {
// onError will be called for any connection errors. // onError will be called for any connection errors.
virtual bool start(int port, virtual bool start(int port,
const OnConnect& callback, const OnConnect& callback,
const OnError& onError = OnError()) = 0; const OnError& onError = IgnoreErrors) = 0;
// stop() stops listening for connections. // stop() stops listening for connections.
// stop() is implicitly called on destruction. // 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