Skip to content

Upgrading

Percs edited this page Apr 29, 2024 · 9 revisions

Picking a transport

Newer versions of Ultraviolet use bare-mux, a way to switch bare clients easily. To do this, you must pick a transport to install and use on your service. Some examples of ones are EpoxyTransport, CurlTransport, and Bare-Client.

Adding the transport

Transports run in the service worker, which requires you to import them into the service worker. This is as easy as downloading the transport and importing it into your existing service worker like shown below.

importScripts('/path/to/transport/index.js');

This should also be imported in the main thread via a script tag or other means.

<script src="/path/to/transport/index.js" defer></script> 

You can have multiple transports imported and switch between them using bare-mux.

Switching transports

If using a bundler, it is as easy as calling SetTransport imported from bare-mux.

import { SetTransport } from '@mercuryworkshop/bare-mux';

SetTransport("EpxMod.EpoxyClient", { wisp: "wss://wisp.mercurywork.shop/" });
SetTransport("BareMod.BareClient", "https://example.com/bare/");

If not using a bundler, include the bare.cjs file in releases and call BareMux.SetTransport from the document.

You should also be sure to import bare-mux into the service worker as shown above with the transports.

Your transport should get set after the service worker is ready, otherwise this may cause issues.