Skip to content

JS SDK



A SDK client for interacting with the SAMA chat server from Web/Node.js apps.

  1. Install packge to your app:

    Terminal window
    npm install @sama-communications/sdk
  2. Create an SDK sample and store it in a variable:

    import { SAMAClient } from "@sama-communications/sdk";
    const config = {
    endpoint: {
    ws: "wss://your-websocket-url"
    http: "https://your-websocket-url.com"
    }
    }
    const client = new SAMAClient(config);
  3. All done. Try out the methods above.

    client
    .connect()
    .then(() => {
    console.log("Connected to the server");
    })
    .catch((error) => {
    console.error("Failed to connect to the server:", error);
    });
    client
    .userLogin({ login: "user_login", password: "user_password" })
    .then((response) => {
    console.log("User logged in:", response);
    })
    .catch((error) => {
    console.error("Failed to log in:", error);
    });