# Chatting

옴니톡 SDK가 제공하는 채팅 기능은 모든 room\_type에서 기본으로 제공됩니다. 상대방과 음성이 연결되는 시점부터 채팅 기능을 사용할 수 있습니다.

## 메세지 전송

[sendMessage()](/typescript/api-reference.md#sendmessage) API 를 사용하여 같은 룸에 참여한 모든 사용자에게 채팅 메세지를 전달할 수 있습니다. message의 최대 길이는 2048자 입니다.

```typescript
await sdk.sendMessage(message);
```

## 귓속말 전송

[sendWhisper()](/typescript/api-reference.md#sendwhisper) API 를 사용하여 특정 사용자에게 귓속말 메세지를 전달할 수 있습니다. 첫번째 파라미터인 message의 최대 길이는 2048자 입니다. 두번째 파라미터는 귓속말을 보내고자 하는 대상의 session을 전달하시면 됩니다.

```typescript
await sdk.sendWhisper(message, target_session);
```

## 이벤트 수신

이벤트 메세지 수신 방법은 [이벤트 리스너 등록](https://docs.omnitalk.io/typescript/developers-guide/pages/w8ACkJxajWMoTKkdX6Xw#2.) 를 참고 바랍니다. 채팅 메세지의 이벤트 이름은 `MESSAGE_EVENT` 입니다. 채팅 이벤트 메세지의 종류는 4가지로, message action으로 구분됩니다.

* send: 특정 참가자가 **채팅 메세지를 전송** 했을 때, **다른 참가자들에게 발생**하는 이벤트 메세지
* whisper: 특정 참가자가 다른 참가자에게 **귓속말을 전송** 했을때, **귓속말 대상자에게 발생**하는 이벤트 메세지
* join: 새로운 **참가자가 입장** 했을 때, **다른 참가자들에게 발생**하는 이벤트 메세지
* leave: **참가자가 퇴장** 했을 때, **다른 참가자들에게 발생**하는 이벤트 메세지


---

# 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/typescript/developers-guide/chatting.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.
