In practice, there will always be one single instance of The SIMPL-Games-API service, and for every simulation you will write a model service, and a frontend service. The browser will use the frontend service for the static assets (HTML and JS), and connect to the model service in order to receive/send events through the WebSocket.

The SIMPL-Games-API service will send events to your model service via HTTP Webhooks, and they will be automatically forwared to the browser.

Your model service itself will send message to the browser or listen to message from it, and will make REST API calls to the SIMPL-Games-API service as needed (eg to store state).

    |                `SIMPL-Games-API`                |
              | A                         | A
     Webhooks | |  REST API      Webhooks | |  REST API
              V |                         V |
   +-------------------+          +-------------------+ 
   | modelservice sim1 |          | modelservice sim2 | 
   +-------------------+          +-------------------+
        A           A                 A           A
        | WAMP      | WAMP            | WAMP      | WAMP
        V           V                 V           V
+-----------+  +-----------+  +-----------+  +-----------+
| Browser 1 |  | Browser 2 |  | Browser 3 |  | Browser 4 |
+-----------+  +-----------+  +-----------+  +-----------+
     A               A             A               A
     | Static        | Static      | Static        | Static
     | assets        | assets      | assets        | assets
   +-------------------+         +-------------------+ 
   |   frontend sim1   |         |   frontend sim2   | 
   +-------------------+         +-------------------+

The WAMP Layer

The communication between the modelservice and the browser happens via Websocket by using the WAMP Protocol.

Thw WAMP Protocol is mainly composed of two patterns: publish/subscribe (PubSub in short) and call/register (or RPC).

PubSub vs RPC

The main difference between PubSub and RPC is that a call to a registered procedure returns a value, where publishing to a topic does not. Both are asynchronous operations, but with RPC you can wait on the returned value and tell when the operation has completed.

As a rule of thumb: use RPC if you need to get data from the modelservice. Otherwise you can use PubSub.