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.
This commit is contained in:
parent
cc7b68a365
commit
eab43f3518
@ -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 {
|
|||||||
// 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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user