tinyweb icon indicating copy to clipboard operation
tinyweb copied to clipboard

websockets

Open davidmoshal opened this issue 4 years ago • 6 comments

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

davidmoshal avatar Oct 24 '21 21:10 davidmoshal

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

belyalov avatar Oct 24 '21 21:10 belyalov

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:

  • https://github.dev/marcidy/micropython-uasyncio-webexample/websockets/protocol.py

davidmoshal avatar Dec 21 '21 05:12 davidmoshal

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

belyalov avatar Dec 21 '21 17:12 belyalov

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

Dave

davidmoshal avatar Dec 21 '21 19:12 davidmoshal

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)

davidmoshal avatar Dec 25 '21 15:12 davidmoshal

Are websockets supporting now ?

akshaydusane93 avatar Mar 11 '22 04:03 akshaydusane93