# Unreal Engine 4

Download the ProudChat Unreal Engine 4 SDK from the link below.

## :open\_file\_folder: [Unreal Engine 4 ProudChat SDK](https://github.com/Nettention/ProudChatSDK/tree/main/ChatClientSDK/Unreal)

## Project settings

### - Plugins settings

In the project root folder, create a new <mark style="color:orange;">Plugins</mark> folder and copy the downloaded SDK file to the Plugins folder you created.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/ekn4roZXB9dteKWcxNlF/ue%20plugins%20.png" alt=""><figcaption></figcaption></figure>

In the Unreal Editor, press <mark style="color:orange;">Edit</mark> -> <mark style="color:orange;">Plugins</mark> to check whether the ProudChat plugin you copied is enabled in the Plugin Browser tab.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/KXjH2oIyVt0l93Vbs5jO/ue%20sdk.png" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If you don't see the ProudChat plugin in the Unreal Editor after copying it to the Plugins folder, you can check by exiting and re-launching the editor.
{% endhint %}

### - Setting Up Blueprint Classes

After the plugin is successfully installed, the <mark style="color:orange;">ProudChat C++ class</mark> Browser in the Unreal Editor creates a 'Blueprint class' based on the <mark style="color:orange;">ProudChatActor</mark> class.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/kVHF0eRhPfRSecMFkRhv/ue-blueprint.png" alt=""><figcaption></figcaption></figure>

In the Event Graph of the 'Blueprint class' you created, create an <mark style="color:orange;">Init</mark> function for Proud Chat, connect it to the <mark style="color:orange;">BeginPlay</mark> event, and enter the <mark style="color:orange;">Account UUID</mark>, <mark style="color:orange;">Project UUID</mark>, and User <mark style="color:orange;">UniqueID</mark> that you received from the Proud Console.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/IlY2oso77U7M9HTZE4xS/ue-blueprint1.png" alt=""><figcaption></figcaption></figure>

After compiling the event by pressing the Compile button, place the created 'Blueprint Class' in your Level and press Play to see if it connects to the server.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/z0ajw2YYfO9hdsoo1ijZ/ue-blueprint2.png" alt=""><figcaption></figcaption></figure>

If the connection is successful, ProudChat Connection Success is displayed in the top-left corner of the level.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/ubalxmYkN5ielbMH292n/ue-blueprint3.png" alt=""><figcaption></figcaption></figure>

## ProudChatActor

### - ProudChatActor::Init

This is the part that initializes ProudChat. The user must call the <mark style="color:orange;">Init</mark> function to connect to the server before using it.

<table data-full-width="false"><thead><tr><th width="134">Function Name</th><th width="278">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>Init</td><td>The user's UUID provided in the <a href="https://console.nettention.com"><strong>Proud Console</strong></a>, the UUID of the project the user created, and the user's own UniqueID.</td><td>The user writes this part of the function to connect ProudChat.<br>We're taking 3 strings as parameters, but internally we're calling the <mark style="color:orange;">ChatClientInitComplete</mark>,  <mark style="color:orange;">ChatClientInitFailed</mark> events via <mark style="color:orange;">std::bind</mark> so we can see if the login succeeded or failed.</td></tr></tbody></table>

### - Disconnect

<table data-full-width="false"><thead><tr><th width="186">Function Name</th><th width="206">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>Disconnect</td><td>-</td><td>Use when you want to disconnect with the chat server.</td></tr></tbody></table>

### - Functions

<table data-full-width="false"><thead><tr><th width="204">Function Name</th><th width="317">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>IsConnected</td><td>-</td><td>Use when you check the status of server connection.</td></tr><tr><td>JoinChannel</td><td>Unique key for the channel you want to access</td><td>Use when you want to access a specific channel.</td></tr><tr><td>LeaveChannel</td><td>Unique key for the channel you want to leave</td><td>Use this when you want to leave the channel you're in.</td></tr><tr><td>SendChannelMsg</td><td>A unique identification value for a specific channel, a message to send to the specific channel</td><td>Use to send a message to a specific channel.</td></tr><tr><td>SendDirectMsg</td><td>A unique identification value for a specific recipient, a message to send to the specific party</td><td>Use to send a message to a specific person.</td></tr><tr><td>MsgTranslate</td><td><p>src = The country code of current language</p><p>target = The country code of the targeting language</p><p>msgKey = A unique key of message to translate</p><p>msg = A message to translate</p></td><td>(Beta) Use when you want to translate the message</td></tr><tr><td>MsgTranslate_Auto</td><td><p>target = The country code of the targeting language</p><p>msgKey = A unique key of message to translate </p><p>msg = A message to translate</p></td><td>(Beta) Request the translation of the message after automatically detecting the language.</td></tr><tr><td>MsgRecord_Channel</td><td>channelKey = A unique key of the channel<br>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the chat data from the Channel. <br>Retrieve up to 100 messages within the last 90 days.</td></tr><tr><td>MsgRecord_Direct</td><td>target = A unique key of the target user<br>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the data from the Direct messages.<br>Retrieve up to 100 messages within the last 90 days.</td></tr><tr><td>MsgRecord_Notice</td><td>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the data from the Notice.<br>Retrieve up to 100 messages within the last 90 days.</td></tr></tbody></table>

### - Event Variables (C++)

<table data-full-width="false"><thead><tr><th width="309">Event variable name</th><th>Description</th></tr></thead><tbody><tr><td>InitComplete_Delegate</td><td>Event called when <mark style="color:orange;">Init Complete</mark> completes.</td></tr><tr><td>InitFailed_Delegate</td><td>Events called when <mark style="color:orange;">Init Failed</mark>.</td></tr><tr><td>ChatDisconnect_Delegate</td><td>Event fired when the chat server <mark style="color:orange;">disconnected</mark>. </td></tr><tr><td>ChannelMsg_Response_Delegate</td><td>It handles events that occur if a <mark style="color:orange;">ChannelMsg</mark> arrives.</td></tr><tr><td>DirectMsg_Response_Delegate</td><td>It handles events if the <mark style="color:orange;">DirectMsg</mark> arrives between users.</td></tr><tr><td>Notice_Response_Delegate</td><td>It will be called when you send <mark style="color:orange;">Notice</mark> from Proud Console.</td></tr><tr><td>Channel_Join_Success_Delegate</td><td>It will be called if <mark style="color:orange;">Channel Join Success</mark> occurs.</td></tr><tr><td>Channel_Join_Failed_Delegate</td><td>It will be called if <mark style="color:orange;">Channel Join Failed</mark> occurs.</td></tr><tr><td>Channel_Leave_Success_Delegate</td><td>It will be called if <mark style="color:orange;">Channel Leave Success</mark> occurs.</td></tr><tr><td>Channel_Leave_Failed_Delegate</td><td>It will be called if <mark style="color:orange;">Channel Leave Failed</mark> occurs.</td></tr><tr><td>MsgTranslate_Success_Delegate</td><td>(Beta) It will be called if the message is successfully translated.</td></tr><tr><td>MsgTranslate_Failed_Delegate</td><td>(Beta) It will be called if the message translation fails.</td></tr><tr><td>MsgRecord_Success_Delegate</td><td>(Beta) It will be called if the data history is successfully retrieved.</td></tr><tr><td>MsgRecord_Failed_Delegate</td><td>(Beta) It will be called if the data history retrieval fails.</td></tr></tbody></table>

### - Event Variables (Blueprint)

<table data-full-width="false"><thead><tr><th width="237">Event variable name</th><th>Description</th></tr></thead><tbody><tr><td>ChatClientInitComplete</td><td>It will be called if the server successfully connects with the ChatClient.</td></tr><tr><td>ChatClientInitFailed</td><td>It will be called on server login failure.</td></tr><tr><td>ChatDisconnect</td><td>It will be called if the server disconnects with the ChatClient.</td></tr><tr><td>ChannelMsg_Response</td><td>It handles events that occur if a <mark style="color:orange;">ChannelMsg</mark> arrives.</td></tr><tr><td>DirectMsg_Response</td><td>It handles events if the <mark style="color:orange;">DirectMsg</mark> arrives between users.</td></tr><tr><td>Notice_Response</td><td>It will be called when you send <mark style="color:orange;">Notice</mark> from Proud Console.</td></tr><tr><td>Channel_Join_Success</td><td>It will be called if <mark style="color:orange;">Channel Join Success</mark> occurs.</td></tr><tr><td>Channel_Join_Failed</td><td>It will be called if <mark style="color:orange;">Channel Join Failed</mark> occurs.</td></tr><tr><td>Channel_Leave_Success</td><td>It will be called if <mark style="color:orange;">Channel Leave Success</mark> occurs.</td></tr><tr><td>Channel_Leave_Failed</td><td>It will be called if <mark style="color:orange;">Channel Leave Failed</mark> occurs.</td></tr><tr><td>MsgTranslate_Success</td><td>(Beta) It will be called if the message is successfully translated.</td></tr><tr><td>MsgTranslate_Failed</td><td>(Beta) It will be called if the message translation fails.</td></tr><tr><td>MsgRecord_Success</td><td>(Beta) It will be called if the data history is successfully retrieved.</td></tr><tr><td>MsgRecord_Failed</td><td>(Beta) It will be called if the data history retrieval fails.</td></tr></tbody></table>

## Building

### - Android

Please refer to the links below.

{% hint style="info" %}
[<mark style="color:blue;">**Android Quickstart**</mark>](https://docs.unrealengine.com/5.3/ko/setting-up-unreal-engine-projects-for-android-development/)
{% endhint %}

### - iOS

{% hint style="info" %}
For more information, see [**Building iOS**](https://docs.proudnet.com/proudnet.eng/proudnet/2.setting/unreal-engine-4#4.-ios)**.**
{% endhint %}
