inexorgame-obsolete / deprecated-cube-engine-inexor

UNMAINTAINED: Please have a look at the vulkan-renderer
https://inexor.org
zlib License
11 stars 1 forks source link

Provide the Inexor Tree to user interfaces via websockets #442

Closed aschaeffer closed 7 years ago

aschaeffer commented 7 years ago

The user interfaces (ui-flex, ui-client-hud, ui-client-menu, ui-console) need to get informed about changes on the Inexor Tree. The general problem is that a node, a sub tree or even the complete tree has to be pulled (even if there aren't any changes). Using websockets changes on the tree can be transferred without delay and is limited to the changed node only. This way we have way less overhead and faster response times.

Goal

Note: This is the most usable way until there is real support for GRPC clients on browser side which connects directly to Inexor Core (C++).

Tasks

Using the websockets

  var exampleSocket = new WebSocket("ws://localhost:31416/api/v1/ws/tree", "protocolOne");
  exampleSocket.onmessage = function (event) {
    let response = event.data;
    console.log(response);
  };

Output

...
{"state":"sync","datatype":"int64","path":"/instances/31417/rendering/screen/fullscreen","value":0}
{"state":"sync","datatype":"int64","path":"/instances/31417/rendering/screen/scr_w","value":800}
{"state":"sync","datatype":"int64","path":"/instances/31417/rendering/screen/scr_h","value":600}
...

See also

These technologies also try to bring GRPC support to the web browser.

aschaeffer commented 7 years ago

Done: https://github.com/inexorgame/ui-client-hud/commit/92956a48628c96cd9771924d204b13fbcac90d03