File tree 2 files changed +28
-2
lines changed
libraries/ESP8266WiFi/src 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ bool WiFiServer::hasClient() {
115
115
return false ;
116
116
}
117
117
118
- WiFiClient WiFiServer::available (byte* status) {
118
+ WiFiClient WiFiServer::accept (byte* status) {
119
119
(void ) status;
120
120
if (_unclaimed) {
121
121
WiFiClient result (_unclaimed);
@@ -135,6 +135,24 @@ WiFiClient WiFiServer::available(byte* status) {
135
135
return WiFiClient ();
136
136
}
137
137
138
+ WiFiClient WiFiServer::available () {
139
+ for (uint8_t i = 0 ; i < MAX_MONITORED_CLIENTS; i++) {
140
+ WiFiClient& client = connectedClients[i];
141
+ if (client && client.status () == CLOSED) {
142
+ client = WiFiClient ();
143
+ }
144
+ if (!client) {
145
+ client = accept ();
146
+ }
147
+ }
148
+ for (uint8_t i = 0 ; i < MAX_MONITORED_CLIENTS; i++) {
149
+ WiFiClient& client = connectedClients[i];
150
+ if (client.available ())
151
+ return client;
152
+ }
153
+ return WiFiClient ();
154
+ }
155
+
138
156
uint8_t WiFiServer::status () {
139
157
if (!_listen_pcb)
140
158
return CLOSED;
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ extern "C" {
65
65
class ClientContext ;
66
66
class WiFiClient ;
67
67
68
+ #ifndef MAX_MONITORED_CLIENTS
69
+ #define MAX_MONITORED_CLIENTS 5
70
+ #endif
71
+
68
72
class WiFiServer : public Server {
69
73
// Secure server needs access to all the private entries here
70
74
protected:
@@ -74,13 +78,17 @@ class WiFiServer : public Server {
74
78
75
79
ClientContext* _unclaimed;
76
80
ClientContext* _discarded;
81
+
82
+ WiFiClient connectedClients[MAX_MONITORED_CLIENTS];
83
+
77
84
enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault;
78
85
79
86
public:
80
87
WiFiServer (const IPAddress& addr, uint16_t port);
81
88
WiFiServer (uint16_t port);
82
89
virtual ~WiFiServer () {}
83
- WiFiClient available (uint8_t * status = NULL );
90
+ WiFiClient accept (uint8_t * status = NULL );
91
+ WiFiClient available ();
84
92
bool hasClient ();
85
93
void begin ();
86
94
void begin (uint16_t port);
You can’t perform that action at this time.
0 commit comments