# C++

通過下面的GitHub鏈接下載ProudChat C++ SDK。

## :open\_file\_folder: [C++ ProudChat SDK](https://github.com/Nettention/ProudChatSDK/tree/main/ChatClientSDK/CPlusPlus/ProudChat)

## 項目設置

複製通過git下載的SDK文件到您使用的路線項目的路徑後，在visual studio的解決方案瀏覽器中打開相應項目文件的屬性窗口。

### 1.  ProudNet 頭檔

<figure><img src="/files/HSu31ZU7HNoFXwoYECMZ" alt=""><figcaption></figcaption></figure>

屬性窗口的 <mark style="color:orange;">C/C++</mark> - 在<mark style="color:orange;">附加包含目錄</mark>中， 在安裝有 ProudNet 的文件夾路徑中添加 include 文件夾 。

### 2. 配置庫 < ProudNetClient.lib> 目錄路徑

<figure><img src="/files/8sX39BJFS98Z1gzRjvDs" alt=""><figcaption></figcaption></figure>

在<mark style="color:orange;">連接器</mark> - <mark style="color:orange;">一般</mark>屬性視窗中，在ProudNet安裝資料夾路徑下新增lib - x64 - v140的Debug或Release資料夾。

### 3. 配置庫 < ProudNetClient.lib> Dependencies

<figure><img src="/files/iAH4H4HhDWf4qUNce5Si" alt=""><figcaption></figcaption></figure>

在屬性視窗中的<mark style="color:orange;">連接器</mark> - <mark style="color:orange;">輸入</mark>中新增的庫目錄中新增 ProudNetClient.lib 檔案。

{% hint style="warning" %}
配置 Debug 和 Release 配置。
{% endhint %}

### 4. 新增ChatClient&#x20;

在您使用的項目中包含ChatClient後，生成ChatClient客體後使用即可。

## ChatClient 對象

### - 創建

```cpp
using namespace Proud;

ProudChat::CChatClient* chatClient = new ProudChat::CChatClient();
```

### - ChatClient::Init

進行ChatClient Initialize的部分。 用戶在使用前必須調用Init函數與服務器連接。

<table data-full-width="true"><thead><tr><th width="110">函數名</th><th>參數</th><th>註釋</th></tr></thead><tbody><tr><td>Init</td><td><a href="https://console.nettention.com"><strong>Proud Console</strong></a>提供的<mark style="color:orange;">用戶的UUID</mark>、<mark style="color:orange;">用戶生成的項目的UUID</mark>、<mark style="color:orange;">用戶固有的UniqueID</mark>、Server Connection成功時呼叫的活動、Server Login失敗時呼叫的活動</td><td>用戶將 ChatClient 作爲與服務器連接的函數來編寫此部分 。<br>參數包括項目初始化所需的字符串(<mark style="color:orange;">authUUID</mark>,  <mark style="color:orange;">projectUUID</mark>, <mark style="color:orange;">uniqueID</mark>)和確認登錄成功、失敗與否的活動2個。</td></tr></tbody></table>

### - 函數

<table data-full-width="true"><thead><tr><th width="191">函數名</th><th width="264">參數</th><th>註釋</th></tr></thead><tbody><tr><td>Add_Channel</td><td>您想要訪問的頻道的固有Key</td><td>用於連接特定頻道時 。</td></tr><tr><td>Leave_Channel</td><td>想播出的頻道的固有Key</td><td>想退出連接的頻道時使用。</td></tr><tr><td>Send_Msg</td><td>特定對方固有的識別值， 要發送給特定對象的消息</td><td>用於向特定對象發送信息。</td></tr><tr><td>Send_ChannelMsg</td><td>特定渠道的獨特識別值， 要發送給特定頻道的消息</td><td>用於向特定頻道發送消息。</td></tr></tbody></table>

### - 事件變數

<table data-full-width="true"><thead><tr><th width="290">事件變數名</th><th>註釋</th></tr></thead><tbody><tr><td>chatClientJoinCompleteDelegate</td><td>完成Server Connection後，如果Login成功，將被調用變量。</td></tr><tr><td>chatClientJoinFailedDelegate</td><td>Server Login 失敗時調用的一個變量。<br>使用此函數的時間是連接服務器成功但無法登錄賬戶時發生的事件 。<br>這部分失敗時不會重試，因此需要確認設置。</td></tr><tr><td>channelMsg_ResponseDelegate</td><td>處理 ChannelMsg 到達時發生的事件 。<br>接收<mark style="color:orange;">來自消息通道的 Unique ID</mark> 和<mark style="color:orange;">創建消息的 Unique ID</mark> 以及<mark style="color:orange;">對方發送的消息</mark>作爲參數。</td></tr><tr><td>sendMsg_ResponseDelegate</td><td>處理用戶間Send_Msg到達時發生的事件。<br>接收<mark style="color:orange;">創建消息的 Unique ID</mark> 和<mark style="color:orange;">對方發送的消息</mark>作爲參數。</td></tr><tr><td>noticeDelegate</td><td>ProudConsole 發生通知時調用的事件</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.proudnet.com/proudnet.cn/proudchat/download/c++.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.
