-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiFiServer - don't inherit from Print and Server #8930
WiFiServer - don't inherit from Print and Server #8930
Conversation
because print-to-all-clients is not implemented
@JAndrassy - I understand that this PR wants to make But looking into Arduino.cc implementation for I'm not sure why we should follow ESP8226 and not the UpStream Arduino implementation. Could you please elaborate more about it? I also found an Arduino.cc example that uses Print Class Therefore, the changes proposed in this PR would not allow this example to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain more about the change.
this PR a cleanup suggestion. removing code which never worked. what is unclear in the description of the PR in the first comment? you can read more about the 'Arduino' server.available() and print-to-all-clents here. The esp8266 and esp32 WiFiServer don't implememt that. |
I was thinking about better explanation: |
Same here, we are not able to merge. We need to keep align with Arduino.cc and this introduce a breaking change, closing. Thanks for understanding. |
do you plan to implement the print-to-all-clents function? make the this example must work https://github.com/JAndrassy/Arduino/blob/d5eb265f78bff9deb7063d10030a02d021c8c66c/libraries/ESP8266WiFi/examples/PagerServer/PagerServer.ino#L61 in esp8266 core https://github.com/JAndrassy/Arduino/blob/master/libraries/ESP8266WiFi/src/ArduinoWiFiServer.h |
👋 Hello JAndrassy, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Arduino has a base class Server. It is inherited from the Print class. The official base class Server has only
virtual void begin()=0;
. The Server class can't declare other required server methodsavailable()
andaccept()
, because they have the return type of the specific Client implementation of the library (for example EthernetClient in the Ethernet library). In ESP32 core the Server class is even modified (so external networking libraries produce an error).. It is not possible to use the base class Server to work with an instance of an inherited class.Class Server inherits from Print for the print-to-all-clients functionality. This functionality is tied with a proper
available()
method implementation. The implementation of the Server class should register all connected clients for correct implementation ofavailable()
and for print-to-all-clients functionality. The ESP32 WiFiServer doesn't manage clients for available() and print-to-all-clients. The write method is unimplemented.This PR removes the inheritance from Server and Print. ESP8266 did it almost two years ago. For ESP8266 I wrote ArduinoWiFiServer which inherits from WiFiServer and Print and manages the clients for proper
available()
and print-to-all-clients. But I doubt somebody uses it. My NetApiHelpers library has ArduinoWiFiServer for ESP32, older version of esp8266 and MbedCore