danni / uwebsockets

Micropython websockets implementation
MIT License
192 stars 44 forks source link

implement an asyncio version of the websocket class #13

Open RobertBlackhart opened 4 years ago

RobertBlackhart commented 4 years ago

This change allows the uwebsockets package to be used inside of a uasyncio application by using the StreamWriter and StreamReader classes.

The client and protocol logic is almost not touched at all other than to change the method of reading and writing.

danni commented 4 years ago

This looks pretty good. Truthfully, I wonder if this should be the default implementation. I would have made it the default implementation originally (there's a branch even), but asyncio wasn't implemented on the target ESP platform at the time. What do you think? There's not a lot of point in maintaining two implementations (truthfully I don't even maintain one implementation).

RobertBlackhart commented 4 years ago

I'm not sure about default vs. not. The times I've used websockets in past projects, it's always been in an asynchronous way. But if someone wanted to use them in a synchronous project and this was the default, they would have to do some gymnastics due to the async keyword.

busslina commented 1 year ago

@RobertBlackhart Hello, have you tested it widely? Arey you crrently using your fork lib? I'm interested in using it. Or maybe you know about other alternatives to use websocket on Micropython (Pi Pico).

Thank you

RobertBlackhart commented 1 year ago

I'm afraid that the project that I made this change for was shelved. In my limited testing it was working, but I wasn't using it in anything I would call production-ready and I haven't even run it in a few years. Sorry I don't have much more experience I can offer besides what's in the diff and the thread here.

If you decide to try it, don't forget to update if it's working for you so that the next person has more to go on :)

busslina commented 1 year ago

@RobertBlackhart okay, thank you. I will try to use the C/C++ way but if I achieve any improvement here I will let you know ;)