Skip to main content

Quick Setup

To start using ART for your project, the first thing to do is create an account. After registering, Log-In to your ART account, you'll gain access to the ART admin console. Our interactive and intuitive admin console serves as the single entry point for all ART configurations and also for obtaining your Client Secret Key, which is essential for authenticating the ADK setup.


By following the instructions below, you'll complete the crucial setup needed to begin working on your first project with ART i.e. installing the ADK and generating your Client Secret Key.

1. ADK Installation

ADK is the fundamental component that acts as a bridge, allowing your applications to communicate with ART Live and utilize its features and services. To connect to the ART services and use the features, you just need to install the ADK suitable for the technology of your choice.

Here's the example of installing Javascript ADK:

npm install @arealtimetech/adk-js

After installing, import the ADK to your project

import Adk from '@arealtimetech/adk-js';

To learn more about the available ADKs and using them, visit the ART ADK Documentation

tip

Our Javascript ADK is now available in npm. Check it out!

ART Javascript ADK

2. Client Secret Key Generation

The Client Secret is important key to authenticate the application with the ART. Without the valid credentials, your project will not connect and be able to use ADK services. The client secret can be generated from App settings menu or personal settings in ART dashboard.

You can learn to generate clinet secret in the Client Configuration Documentation

3. Add Client Keys to Your Project

The generated Client secret can be copied or downloaded as JSON. By default you'll see the file name as adk-service.json while downloading. If copied, you need to paste it in a new JSON file created with the same name.

Once downloaded or saved, move the file to root of your project directory. This step is crucial, as the installed ADK will actively look for this file to authenticate the application.

The Client credentials should look something like this:

{
"Client-ID": "xxxxxxxxxx",
"Client-Secret": "xxxxxxxxxxx",
"Org-Title": "YOUR_ORG",
"ProjectKey": "YOUR_PROJECT_KEY",
"Environment": "YOUR_ENV_NAME"
};
important

The Client Credential JSON won't have the ProjectKey and Environment when generated. They need to be updated manually.

To learn more about obtaining Project key and Environment name, click here

Once the basic configuration is done, you can proceed with configuring all the components to cater your needs.

4. Authentication and Initialization

The client application needs to be authenticated with ART before getting access to the services. To authenticate, user needs to generate passcode

The generated passcode is used in authentication process.

const adk = new Adk({
AuthToken: "YOUR_PASS_CODE", // Replace with your obtained passcode
Uri: "ws.arealtimetech.com", // Replace with ART server WebSocket URI
});

// Initiate the connection to the ART server
adk.connect();

Once the authentication is done and connection is established, you are good to go with using the ADK services in your application.

Channel subscription, pushing and listening to messages

A channel acts as a dedicated communication conduit within the ART ecosystem. To enable the client to either push or listen for messages, channel subscription is necessary.

Subscribbe to Channel if exists, or create new from Live Connect Dashboard to send or listen to messages.

// Listen for a successful connection event
adk.on("open", () => {
console.log("Successfully connected to ART WebSocket server.");
});

// Handle any connection errors
adk.on("error", (err) => {
console.error("ART ADK Connection Error:", err);
});

// Handle connection close event
adk.on("close", () => {
console.log("ADK connection closed");
});

// Subscribe to your channel
const subscription = adk.subscribe("YOUR_CHANNEL_NAME");

// Send an event with payload to specific users
const payload = {
message: "Hello!",
};

subscription.push("EVENT", payload, {
to: ["username1", "username2"], // Target user list is needed only for Targeted and Encrypted channel types.
});

// Listen to all events and messages in the channel
subscription.listen((data) => {
console.log("Received:", data);
});

adk.disconnect();

This covers the basic setup and introduction to how ADK works with ART. These fundamental steps will get you started with realtime communication in your applications. Feel free to explore the comprehensive documentation to discover advanced features, configuration options, and best practices that can enhance your project's capabilities.