alfred82santa / whalesong

Whalesong is an asyncio python library to manage WebApps remotely. Currently WhatsappWeb is implemented
https://whalesong.readthedocs.io
MIT License
51 stars 19 forks source link

Remote communication protocol for whalesong #89

Open parthibd opened 5 years ago

parthibd commented 5 years ago

I recently wrote a question regarding REST API for whalesong . I was suggested to use websockets and webhooks . I made a very preliminary but working API with REST using aiohttp . I am planning to implement webhhooks/websocket for event notification . I chose REST . The code is not up in github yet because I want to test it out before it goes public.

Any suggestions or ideas will be really helpful to guide me in the right way.

alfred82santa commented 5 years ago

Well, when you define an asynchronous protocol you need a way to know which response is related with which request. So, you need some identifier on request, which will be used on responses. It could be set by client (it avoid race-condition errors on client) or it could be set by server (it simplify api usage). Further, with bi-directional protocol you need three kinds of responses: final, partial and error. Final is used as response for request which has just one response, they could be implemented as rest api. Partials responses are used for requests which could has one or more response, for example when you connect to an event. Error responses, well, they are used when something fails.

parthibd commented 5 years ago

I was thinking the same . I am implementing the functionality such as sending a text message , or a media message etc over a rest api . The rest api internally creates the driver according to an unique identifier sent by the client . For events such as the driver connected ,disconnected ,logged in etc will be implemented over websockets/webhooks . And for errors it will be implemented over the same protocol as events . Sounds right ?

alfred82santa commented 5 years ago

Well, errors will happen in rest and websocket protocol