Unverified Commit a1902b5f authored by Juraj Andrássy's avatar Juraj Andrássy Committed by GitHub

WiFiServer modernization (#1871)

parent c2d60774
......@@ -90,7 +90,7 @@ void WebServerTemplate<ServerType, DefaultPort>::handleClient() {
_currentClient = nullptr;
}
_currentClient = new ClientType(_server.available());
_currentClient = new ClientType(_server.accept());
if (!_currentClient) {
if (_nullDelay) {
delay(1);
......
......@@ -34,7 +34,7 @@ void loop() {
delay(1000);
Serial.printf("--loop %d\n", ++i);
delay(10);
WiFiClient client = server.available();
WiFiClient client = server.accept();
if (!client) {
return;
}
......
......@@ -163,10 +163,18 @@ void WiFiServer::close() {
_listen_pcb = nullptr;
}
void WiFiServer::end() {
close();
}
void WiFiServer::stop() {
close();
}
WiFiServer::operator bool() {
return (status() != CLOSED);
}
template<typename T>
T* slist_append_tail(T* head, T* item) {
if (!head) {
......
......@@ -75,10 +75,10 @@ protected:
public:
WiFiServer(const IPAddress& addr, uint16_t port);
WiFiServer(uint16_t port);
WiFiServer(uint16_t port = 23);
virtual ~WiFiServer() {}
WiFiClient accept(); // https://www.arduino.cc/en/Reference/EthernetServerAccept
WiFiClient available(uint8_t* status = nullptr);
WiFiClient available(uint8_t* status = nullptr) __attribute__((deprecated("Use accept().")));
bool hasClient();
// hasClientData():
......@@ -95,8 +95,10 @@ public:
bool getNoDelay();
uint8_t status();
uint16_t port() const;
void end();
void close();
void stop();
explicit operator bool();
using ClientType = WiFiClient;
......
......@@ -31,7 +31,7 @@ class WiFiClientSecure;
class WiFiServerSecure : public WiFiServer {
public:
WiFiServerSecure(IPAddress addr, uint16_t port);
WiFiServerSecure(uint16_t port);
WiFiServerSecure(uint16_t port = 22);
WiFiServerSecure(const WiFiServerSecure &rhs);
virtual ~WiFiServerSecure();
......@@ -65,7 +65,7 @@ public:
// If awaiting connection available and authenticated (i.e. client cert), return it.
WiFiClientSecure accept(); // https://www.arduino.cc/en/Reference/EthernetServerAccept
WiFiClientSecure available(uint8_t* status = nullptr);
WiFiClientSecure available(uint8_t* status = nullptr) __attribute__((deprecated("Use accept().")));
WiFiServerSecure& operator=(const WiFiServerSecure&) = default;
......
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