Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.88k stars 555 forks source link

No Async Websocket server for ESP32 #332

Open williamesp2015 opened 6 years ago

williamesp2015 commented 6 years ago

Arduino websocket can configure at Websockets.h #define WEBSOCKETS_NETWORK_TYPE = NETWORK_ESP8266_ASYNC However ESPAsyncTCP support only ESP8266 not ESP32. When I have long duration function like recording fast sensors into SD card (using SdFat), websocket server event is not responsive to use commands for the Stop recording. Any advice would be appreciated.

Links2004 commented 6 years ago

there is a Async variant for the ESP32, https://github.com/me-no-dev/AsyncTCP

but i has a other API then the ESP8266 variant. with some work you may can use it.

williamesp2015 commented 6 years ago

Thanks for the information but if you have a flag or simple function to call for the Websocket Server to just check in a function to know if client sent a message it would help. currently I call webSocket.loop() in my function but message in the webSocketEvent accumulated until GPIO key pressed and I exit the function and come back to the loop(). I want to stop my function by client.

Links2004 commented 6 years ago

async for ESP32 is not implemented in arduinoWebSockets, since I dont have a ESP32 here there is less I can do.

vyruz1986 commented 6 years ago

If you PM me your address I'll gladly send you an ESP32 if that would motivate you to implement this :)

I'm not looking for the WebSocket server (I'm using @me-no-dev EspAsyncWebServer for websocket server purposes, which is already async), I'm looking for an async client instead. I've attempted to implement ESP32 async support using the AsyncTCP library, but I got stuck pretty quickly :(

It seems ESPAsyncTCP had 3 classes you used:

While AsyncTCP offers those first 2 classes with compatible API (at first glance at least, maybe minor fixes needed), it does not offer a counterpart for the AsyncTCPbuffer class. Maybe @me-no-dev can comment on what should be used instead of this buffer? For the WebSocketsClient class the AsyncTCPbuffer class is just used at 2 locations, here and here.

Unfortunately I lack the skills in digging into this further, if anyone has tips that might get me on track again, feel free to comment.