npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sceyt-chat

v1.5.9

Published

JavaScript SDK for integrating Sceyt Chat API into your web applications.

Downloads

62

Readme

SceytChat JavaScript SDK

The SceytChat JavaScript SDK provides developers with a powerful and flexible chat interface that can be easily integrated into JavaScript apps. With SceytChat, you can easily add one-to-one and group chat functionality to your app. It comes packed with a wide range of features, including message threading, media and file sharing, reactions, user mentions, message search, user and channel blocking, message forwarding and replies, and many more.

Table of contents

Installation

To use the SceytChat JavaScript SDK in your project, you can install it via npm or yarn.

npm

To install the SceytChat JavaScript SDK using npm, run the following command:

npm i sceyt-chat

yarn

To install the SceytChat JavaScript SDK using Yarn, run the following command:

yarn add sceyt-chat

Usage

To use the SceytChat SDK in your application, you'll need to initialize it with the following parameters:

  • apiUrl: The URL for the Sceyt Chat API endpoint that the SDK should connect to. You can find this value in the Sceyt managment dashboard. This parameter is required.
  • appId: The unique ID for your Sceyt Chat application. You can find this value in the Sceyt managment dashboard. This parameter is required.
  • clientId The unique ID for your SceytChat client. This parameter should be unique across the instances if you want to use multiple clients of the same user, for example in multiple browser tabs.
  • requestTimeout An optional parameter that specifies the maximum amount of time in milliseconds to wait for a response from the Sceyt Chat API before timing out. If this parameter is not specified, the SDK will use a default timeout of 10000 milliseconds (10 seconds).
import SceytChat from 'sceyt-chat';

const sceytClient = new SceytChat('{apiUrl}', '{appId}', '{clientId}')

Before connecting to the SceytChat service, it's a good idea to add connection listeners to the SceytChat client to handle various events that may occur during the connection process. Here are connection listeners you can add:

// Create a new connection listener
const connectionListener = new sceytClient.ConnectionListener();

// Set the listener function for the 'connectionStatusChanged' event
connectionListener.onConnectionStatusChanged = async (status) => {
  console.log('Connection status changed:', status);
};

// Set the listener function for the 'tokenWillExpire' event
connectionListener.onTokenWillExpire = async (timeInterval) => {
  console.log('Token will expire in', timeInterval/1000, 'seconds');
};

// Set the listener function for the 'tokenExpired' event
connectionListener.onTokenExpired = async () => {
  console.log('Access token has expired');
};

// Add the connection listener to the SceytChat client
sceytClient.addConnectionListener('my-connection-listener', connectionListener);

Before creating a channel and sending messages, make sure the SceytChat client is connected:

// Connect to the Sceyt Chat API with a valid access token
sceytClient.connect('{accessToken}');

Now you can create a new channel with different members and send a message:

const members = [
    {
        role: 'participant',
        id: 'alice'
    },
    {
        role: 'participant',
        id: 'john'
    }
]

const params = {
    type: 'group',
    subject: 'Marketing Group',
    members
}

const marketingGroup = await sceytClient.Channel.create(params);

// Create a message builder to construct a message object for sending
const messageBuilder = marketingGroup.createMessageBuilder();
const messageToSend = messageBuilder
    .setBody('Hey team! How are you doing today?')
    .setType('common')
    .create();

// Send the message
const message = await channel.sendMessage(messageToSend);

License

See the LICENSE file for details.