import { type ClientOptions } from "https://deno.land/x/smoldot2@light-js-deno-v2.0.4/public-types.d.ts";
Configuration of a client.
Properties
One end of a port (created using new MessageChannel
). The other end must be passed to the
run
function found in smoldot/worker
.
If this option isn't set then the smoldot light client will run entirely on the "current thread", which might slow down other components that also run on this thread. If this option is set, then the Client that is created is merely a frontend that sends messages on the provided port.
It is intended that the other end of this port is sent to a background worker, and the
run
function be called in this background worker. However this is in no way mandatory.
Callback that the client will invoke in order to report a log event.
By default, prints the log on the console
. If you want to disable logging altogether,
please pass an empty callback function.
The client will never call the log callback with a value of level
superior to this value.
Defaults to 3.
While this filtering could be done manually in the logCallback
, passing a maximum log level
leads to better performances as the client doesn't even need to generate a message
when it
knows that this message isn't interesting.
Maximum amount of CPU that the client should consume on average.
This must be a number between 0.0
and 1.0
. For example, passing 0.25
bounds the client
to 25% of CPU power.
Defaults to 1.0
if no value is provided.
Note that this is implemented by sleeping for certain amounts of time in order for the average CPU consumption to not go beyond the given limit. It is therefore still possible for the client to use high amounts of CPU for short amounts of time.
If ClientOptions.portToWorker is set, then the CPU rate limit applies to the worker.
If true
, then the client will never open any TCP connection.
Defaults to false
.
This option can be used in order to mimic an environment where the TCP protocol isn't supported (e.g. browsers) from an environment where TCP is supported (e.g. NodeJS).
This option has no effect in environments where the TCP protocol isn't supported anyway.
If true
, then the client will never open any non-secure WebSocket connection.
Defaults to false
.
This option can be used in order to mimic an environment where non-secure WebSocket connections aren't supported (e.g. web pages) from an environment where they are supported (e.g. NodeJS).
This option has no effect in environments where non-secure WebSocket connections aren't supported anyway.
If true
, then the client will never open any non-secure WebSocket connection to addresses
other than localhost
or 127.0.0.1
.
Defaults to false
.
This option is similar to forbidWs
, except that connections to localhost
and 127.0.0.1
do not take the value of this option into account.
This option can be used in order to mimic an environment where non-secure WebSocket connections aren't supported (e.g. web pages) from an environment where they are supported (e.g. NodeJS).
This option has no effect in environments where non-secure WebSocket connections aren't supported anyway.
If true
, then the client will never open any secure WebSocket connection.
Defaults to false
.
This option exists of the sake of completeness. All environments support secure WebSocket connections.