# 項目設定

## 1. 設定項目

根據每個環境設定項目。

### :black\_small\_square: [C++](/proudnet.cn/proudnet/2.setting/c++.md)&#x20;

### :black\_small\_square: [C#](/proudnet.cn/proudnet/2.setting/c.md)

### :black\_small\_square: [Mac Xcode](/proudnet.cn/proudnet/2.setting/mac-xcode.md)

### :black\_small\_square: [Linux](/proudnet.cn/proudnet/2.setting/linux.md)

### :black\_small\_square: [Unity3D](/proudnet.cn/proudnet/2.setting/unity3d.md)

### :black\_small\_square: [Unreal Engine 4](/proudnet.cn/proudnet/2.setting/unreal-engine-4.md)

## 2. 寫入 PIDL 文件

若要將<mark style="color:orange;">Remote Method Invocation(RMI)</mark> 與 ProudNet 結合使用，您必須先建立一個副檔名為 PIDL 的檔案。

PIDL檔案是定義主機之間交換訊息的來源文件，編譯PIDL檔案時，會建立代理程式和存根，並將它們包含在主機程式中。

{% hint style="danger" %}
不要指定高於 60,000 的訊息第一個 ID 值。\
超過 60,000 的值已在 ProudNet 的內部 PIDL 中指定為訊息 ID 值。 如果訊息ID重疊，<mark style="color:orange;">AttachProxy</mark>和<mark style="color:orange;">AttachStub</mark>函數就會出現異常。
{% endhint %}

PIDL檔案的基本使用格式如下：

{% tabs %}
{% tab title="PIDL" %}

```cpp
global <名稱空間> <訊息的第一個ID值>
{
    ([屬性聲明]) <函數聲明> ( [in] 功能參數, ... );
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %} <mark style="color:orange;">**名稱空間**</mark>\
這是編譯 PIDL 檔案時所建立的代理程式和存根模組的 C++ 命名空間名稱。\
ProudNet 可以同時使用兩個或多個代理程式和存根，但相反，必須使用命名空間來解決歧義，因此命名空間至關重要。\
例如，聲明“LobbyC2S”意味著“在遊戲大廳中聲明客戶端->伺服器調用 RMI”。\
\ <mark style="color:orange;">**訊息的第一個ID值**</mark>\
當呼叫 RMI 時，每個 RMI 都會轉換為網路訊息，該訊息的訊息頭中有一個 ID 值。\
需要注意的一點是，用於進程間通訊的多個代理程式和存根的訊息 ID 範圍不能重疊。\
\ <mark style="color:orange;">**屬性聲明**</mark>\
\[in] 必須作出聲明。\
\ <mark style="color:orange;">**函數聲明**</mark>

RMI 函數名稱。\
\ <mark style="color:orange;">**功能參數**</mark>\
類似於C++函數聲明。 允許如下所示的參數聲明，但不允許使用指標類型。

```cpp
int a 
std::vector<int> b
CString c
```

{% endhint %}

PIDL 檔案範例如下：

{% tabs %}
{% tab title="PIDL" %}

<pre class="language-cpp"><code class="lang-cpp"><strong>rename cs(Proud::String, System.String);
</strong><strong>
</strong><strong>global LobbyC2S 5000  // 訊息ID從5000開始
</strong>{
    // ID=5001
    Logon([in] Proud::String name,[in] Proud::String password);
    RequestRoomList([in] int pageNumber); // ID=5002
    Chat([in] Proud::String name); // ID=5003
}
</code></pre>

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**參考**

[**RMI**](/proudnet.cn/proudnet-note/dictionary.md#rmi)

[**RMI 訊息範圍**](/proudnet.cn/proudnet/using_pn/rmi.md#rmi-2)
{% endhint %}

## 3. [運行 PIDL 編譯器](/proudnet.cn/proudnet/2.setting/yun-xing-pidl-bian-yi-qi.md)

運行 PIDL 編譯器。

## 4. [伺服器和客戶端入門](/proudnet.cn/proudnet/using_pn/server_client.md#undefined)

啟動伺服器和客戶端並準備好使用ProudNet。


---

# 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/proudnet/2.setting.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.
