-
-
Notifications
You must be signed in to change notification settings - Fork 140
-
What do you think about introducing a new base class for servers? One based on what is actually useful. It would be more a guide than a useful base class, but for Client and UDP the base classes do an excellent job for consistency of the networking API implementations.
template <class TClient>
class ServerNew {
virtual void begin(uint16_t port) = 0;
virtual void end() = 0;
virtual explicit operator bool() = 0;
virtual TClient accept() = 0;
};
#define CORE_HAS_SERVERNEW
It doesn't require the confusing available method and the never used print-to-all-clients' functionality.
It has parameter port for begin, it doesn't have to be in constructor.
The library authors could ifdef their server class declaration.
class EthernetServer
#ifdef CORE_HAS_SERVERNEW
: public ServerNew<EthernetClient>
#endif
{
or even
class EthernetServer :
#ifdef CORE_HAS_SERVERNEW
public ServerNew<EthernetClient>,
#endif
public Server
{
would work
Here is an overview of Server implementation in libraries
https://github.com/JAndrassy/Arduino-Networking-API/blob/main/ArduinoNetAPILibs.md#server-class
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment