> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/klat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/klat/flutter/channel/join-leave.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/klat/~gitbook/mcp).

# 채널 참여 / 나가기

## 1. 채널에 참여하기

채널에 참여합니다.

{% hint style="info" %}
Public 타입의 채널은 Owner가 초대하지 않아도 사용자가 임의로 참여할 수 있습니다.
{% endhint %}

```dart
TPChannel? channel = await TalkPlusAPI.joinChannel(
    channelId,
    errorCallback: (errorCode, errorMessage){}
);
```

## 2. InvitationOnly 채널에 참여하기

초대 전용 채널에 참여합니다.

{% hint style="info" %}
채널에 정의된 초대 코드(invitationCode)가 필요합니다. 해당 값을 입력하여 초대 전용 채널에 참여할 수 있습니다.
{% endhint %}

```dart
TPChannel? channel = await TalkPlusAPI.joinChannelInvitation(
    channelId, 
    invitationCode,
    errorCallback: (errorCode, errorMessage){}
);
```

## 3. 채널 나가기

채널에서 나갑니다.

{% hint style="info" %}
`deleteChannelIfEmpty` 파라미터를 `true`로 설정하여 채널을 나갈 때 채널에 남아 있는 멤버가 더 이상 없으면 채널이 삭제됩니다.
{% endhint %}

```dart
await TalkPlusAPI.leaveChannel(
    tpChannel, 
    deleteChannelIfEmpty,
    errorCallback: (errorCode, errorMessage){}
);
```
