본문으로 건너뛰기

설치/초기화/연결

Install

npm install gitplelive-chat-sdk

Init

import { ChatClient } from 'gitplelive-chat-sdk';

let gitpleLiveChatClient;
try {
const config = {
host, // gitplelive api host (ex. live.example.com ), Without http:// or https:// or url path
app_id,
};

gitpleLiveChatClient = new ChatClient(config);
} catch (error) {
// handle error
}

Connect

사용자 ID를 사용하여 접속할 수 있습니다. 없는 사용자라면 자동으로 생성됩니다.

정보

좀 더 안전한 접속을 위해 사용자 세션 토큰을 추가로 사용하여 접속할 수 있습니다.

사용자 세션 토큰 사용이 활성화 상태여야 하며, 이 경우 session_token이 필수입니다. Platform API를 사용하여 사용자를 미리 생성하신 후 세션 토큰을 발급받아 사용해주세요.

주의

SDK v1.0.4 미만일 경우 session_token이 필수입니다.

try {
// 기본
const userInfo = { user_id };

// 사용자 세션 토큰 사용시
const userInfo = { user_id, session_token };

await gitpleLiveChatClient.connectUser(userInfo);
} catch (error) {
// handle error
}

Disconnect

try {
await gitpleLiveChatClient.disconnectUser();
} catch (error) {
// handle error
}