Skip to content

npm@sama-communications/sdk



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

We’ve moved all the essential server interaction methods into a separate class. With these methods, you can seamlessly integrate the SDK into your project and use it in your existing components.

This is a demo app to test all these methods https://app.samacloud.io/demo

  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);
    });