Skip to content

Networking

Nikita Sin edited this page Dec 11, 2023 · 1 revision

Supported network protocols

Duit currently supports two main network protocols - HTTP and WebSocket. HTTP is most suitable for distributing “static” content that does not require updating from the server at any time. At the same time, it remains possible to update UI attributes as part of update processing on the server side as a reaction to an action. WebSocket allows you to update the UI at any time if the widget is mounted.

To use a particular transport, you must define the appropriate transport settings when creating a driver instance.

final driver1 = DUITDriver(
  "/layout1",
  transportOptions: HttpTransportOptions(
    defaultHeaders: {"Content-Type": "application/json"},
    baseUrl: "http://localhost:8999",
  ),
);

//or

final driver2 = DUITDriver(
  "ws://localhost:8999",
  transportOptions: WebSocketTransportOptions(),
);
Clone this wiki locally