Interaction between service and remote api using websockets

Viewed 26

I'm trying to create service which will interact between main service and remote api using http and websockets. I need to send data from main platform to API and than react to API incoming events imediantly.

Remote API has two parts: Http and WS. I understand how to interact with http part but don't clearly understand about ws. My main platform, service and sdk wrote by PHP. Also for service I use Redis as DB for save data of incoming events and their statuses. I think I can setup WS server to send data through it to remote API. But I don't see all picture.

scheme that I imagine

How I imagine a hypothetical scenario:

  1. Core platform - create event
  2. My service handle this event, save data to Redis to check and for example change status, format data and send it through my SDK to WS server
  3. WS server has WebSocket connection with remote API. It publish my data to this stream
  4. Remote API get this data and return response
  5. Than, WS server is waiting incoming events from remote API
  6. If server receive incoming data, it send it to my service (or create event which my service will catch?)
  7. When service got incoming data it handle it and create event which main platform can handle

Am I right or it's wrong approach? Welcome to any help and tools titles :)

0 Answers
Related