belyalov / tinyweb

Simple and lightweight HTTP async server for micropython
MIT License
239 stars 40 forks source link

websockets #45

Open davidmoshal opened 2 years ago

davidmoshal commented 2 years ago

Thanks for the great library. Wondering if websockets are possible?

belyalov commented 2 years ago

Hey! ) Thanks for feedback 👍🏻

No, I haven't added web sockets at that time, simply didn't need that few years ago.

But you're warmly welcomed to contribute it! :)

Best

davidmoshal commented 2 years ago

I might just do that! The websocket wire protocol is implemented in other micropython libraries, so I could start with that. Though in all honesty I'm really a Typescript/Kotlin guy, my knowledge of python isn't great.

This would probably be where I'd start:

belyalov commented 2 years ago

That would be great )) Went through the link - does not seem to be complicated..)

davidmoshal commented 2 years ago

@belyalov : ok, I'll try to tackle it over the weekend.

Dave

davidmoshal commented 2 years ago

taking a look at this today.
I think we want to implement socket.io too, for automatic reconnection, topics, etc.

https://github.com/danni/uwebsockets/blob/esp8266/examples/socketio_client.py

So that we can have an api like this:

@socketio.on('topic1')
def on_topic1(message):
    print("message", message)

@socketio.on('topic2')
def on_topic2(message):
    print("alert", message)
akshaydusane93 commented 2 years ago

Are websockets supporting now ?