# Quick Start

Omnitalk SDK를 어떻게 활용할 수 있는지에 대한 간단한 예시입니다. (음성,영상)

## **1. 객체 및 세션 생성**

발급된 Service ID로 Omnitalk 객체와 세션을 생성하는 초기화 과정을 수행합니다. 세션이 정상적으로 생성되면 방 리스트를 조회하거나 방 생성, 방송 개시 및 시청이 가능합니다.

```jsx
Omnitalk.sdkInit("YN3F-GE3M-4CW2-FDLZ");
const sdk = Omnitalk.getInstance();
const session = await sdk.createSession();
```

<table><thead><tr><th width="153">Function</th><th width="152">Description</th><th width="122">Parameter</th><th width="340">Value</th><th>Return</th></tr></thead><tbody><tr><td>sdkInit( )</td><td>sdk 객체 초기화</td><td>service_id</td><td>"YN3F-GE3M-4CW2-FDLZ"</td><td></td></tr><tr><td>getInstance()</td><td>sdk 객체 생성</td><td>-</td><td>-</td><td>Object</td></tr><tr><td>createSession( )</td><td>옴니톡 세션 생성</td><td>-</td><td>-</td><td>Object</td></tr></tbody></table>

## 2. 방 생성

생성된 세션을 바탕으로 방을 만들 수 있습니다. 음성은 "audioroom" 영상은 "videoroom"을 parameter에 전달합니다. 방의 정보가 담긴 JSON Object를 리턴합니다.

```jsx
const roomId = await sdk.createRoom(room_type);
```

<table><thead><tr><th width="161">Function</th><th width="129">Description</th><th>Parameter</th><th>Value</th><th>Return</th></tr></thead><tbody><tr><td>createRoom( )</td><td>방송 생성</td><td>room_type</td><td><p>"audioroom",</p><p>"videoroom"</p></td><td>JSON Object</td></tr></tbody></table>

## 3. 방 목록 조회 및 참여

방 목록을 조회하거나 참여할 수 있습니다. 참여할 방의 room\_id는 방 목록을 조회하여 알 수 있습니다.

```jsx
const roomList = await sdk.roomList(room_type);
const joinResult = await sdk.joinRoom(room_id);
```

<table><thead><tr><th>Function</th><th width="112">Description</th><th width="119">Parameter</th><th>Value</th><th>Return</th></tr></thead><tbody><tr><td>roomList( )</td><td>방송 조회</td><td>room_type</td><td><p>"audioroom",</p><p>"videoroom"</p></td><td>JSON Array</td></tr><tr><td>joinRoom( )</td><td>방송 참여</td><td>room_id</td><td>"b45de3c0167"</td><td>JSON Object</td></tr></tbody></table>

## 4. 방송 개시

로컬의 음성이나 영상을 송출하기 위해서 필요한 과정입니다. call\_type에 송출하고 싶은 종류의 값을 전달 합니다. publish를 수행한 결과를 JSON Object로 리턴합니다.

```jsx
const publishResult = await sdk.publish(call_type);
```

<table><thead><tr><th>Function</th><th>Description</th><th width="147">Parameter</th><th>Value</th><th>Return</th></tr></thead><tbody><tr><td>publish( )</td><td>방송 조회</td><td>call_type</td><td>"videocall", "audiocall"</td><td>JSON Object</td></tr></tbody></table>

## 5. 방송 중인 참여자 조회 및 시청

방에 참여하면 방송 중인 참여자의 목록을 조회하고 시청할 수 있습니다. Subscribe는 영상을 시청할 경우에만 필요하며 특정 사용자의 publish\_idx는 참여자 목록을 조회하면 알 수 있습니다.

```jsx
const publishList = await sdk.publishList(room_id);
const subscribeResult = await sdk.subscribe(publish_idx);
```

<table><thead><tr><th>Function</th><th>Description</th><th width="144">Parameter</th><th>Value</th><th>Return</th></tr></thead><tbody><tr><td>publishList( )</td><td>방송중인 참여자 조회</td><td>room_id</td><td>"b45de3c0167"</td><td>JSON Array</td></tr><tr><td>subscribe( )</td><td>방송 중인 특정 사용자의 영상 시청</td><td>publish_idx</td><td>27</td><td>JSON Object</td></tr></tbody></table>

## 6. 시청 종료 및 세션 종료

특정 사용자의 영상 시청을 종료하거나 방을 나갈 수 있습니다. leave의 parameter로 특정 사용자의 session\_id를 전달하면 방 안에서 특정 사용자의 영상 시청이 종료됩니다. leave의 parameter에 아무것도 전달하지 않으면 로컬의 세션 연결이 종료됩니다.

```jsx
await sdk.leave(session_id);
```

<table><thead><tr><th>Function</th><th>Description</th><th width="187">Parameter</th><th>Value</th><th>Return</th></tr></thead><tbody><tr><td>leave( )</td><td>특정 사용자의 영상 시청 종료 혹은 로컬의 세션 연결 종료</td><td>session_id</td><td>"YjQ1ZGUzYzA3M"</td><td>-</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.omnitalk.io/javascript/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
