Skip to main content
Version: 2.1.x

Connecting to a server

Importing the library

import { connectTo } from "zilaws-client";

if you need them, you can import types too:

import {connectTo, ZilaConnection, WSStatus } from "zilaws-client";

Connecting

Connecting to the server is asynchronous. The first parameter is a standard websocket connection URL string. The second parameter of the connectTo function is optional. It is a callback which gets called when a problem or error happens.

const client = await connectTo("wss://yourhost.com:6589", (reason?: string) => {
console.error("ZilaConnection error happened:\n" + reason);
});