-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Mateusz Dahlke <[email protected]> Co-authored-by: Mateusz Wiktor <[email protected]>
- Loading branch information
1 parent
70cf891
commit 2fd4975
Showing
10 changed files
with
259 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright Epic Games, Inc. All Rights Reserved. | ||
|
||
#include "PubNubModule.h" | ||
#include "Modules/ModuleManager.h" | ||
|
||
IMPLEMENT_MODULE(FDefaultModuleImpl, PubNubModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright Epic Games, Inc. All Rights Reserved. | ||
|
||
using System.IO; | ||
using UnrealBuildTool; | ||
|
||
|
||
|
||
public class PubNubModule : ModuleRules | ||
{ | ||
// select desired module type | ||
|
||
// `posix`, `openssl`, `windows` | ||
private readonly string Option = "posix"; | ||
|
||
// `posix`, `windows` | ||
private readonly string Architecture = "posix"; | ||
|
||
// `sync`, `callback` | ||
private readonly string Implementation = "sync"; | ||
|
||
public PubNubModule(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); | ||
PrivateDependencyModuleNames.AddRange(new string[] { }); | ||
|
||
if (Option == "openssl") { | ||
PublicDependencyModuleNames.AddRange(new string[] { "OpenSSL" }); | ||
} | ||
|
||
var path = Path.Combine(new string[] { ModuleDirectory, "..", ".." }); | ||
var extention = Architecture == "posix" ? "a" : "lib"; | ||
|
||
PublicAdditionalLibraries.Add(Path.Combine(path, Option, $"pubnub_{Implementation}.{extention}")); | ||
PublicIncludePaths.AddRange( | ||
new string[] { | ||
path, | ||
Path.Combine(path, "core"), | ||
Path.Combine(path, "lib"), | ||
Path.Combine(path, Option) | ||
} | ||
); | ||
|
||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public")); | ||
|
||
// Uncomment if you are using Slate UI | ||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); | ||
|
||
// Uncomment if you are using online features | ||
// PrivateDependencyModuleNames.Add("OnlineSubsystem"); | ||
|
||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
THIRD_PARTY_INCLUDES_START | ||
#include "../../ThirdParty/c-core/unreal/pubnub_core.hpp" | ||
THIRD_PARTY_INCLUDES_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright Epic Games, Inc. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Unreal Engine integration | ||
|
||
Our C-core SDK can be used together with [Unreal Engine](https://www.unrealengine.com/en-US). It's **not** a fully functional plugin yet, but can easily be integrated into your project as a [Unreal Engine Module](https://docs.unrealengine.com/5.3/en-US/unreal-engine-modules/). | ||
|
||
## How to setup PubNub C-Core SDK as a Unreal Engine Module | ||
|
||
1. Clone this repository to the `<UnrealProject>/Source/` directory. We recommend that you place it inside the `ThirdParty` folder (create it, if necessary). | ||
|
||
2. Compile the [desired option](https://www.pubnub.com/docs/sdks/c-core#hello-world) of the SDK. You can do it in the SDK directory like so: | ||
|
||
- POSIX: | ||
|
||
```sh | ||
make -C <option> -f <architecture>.mk pubnub_<implementation>.a | ||
``` | ||
|
||
- Windows: | ||
|
||
```sh | ||
nmake -f windows.mk | ||
``` | ||
|
||
- Windows Universal Platform: | ||
|
||
```sh | ||
nmake -f windows/uwp.mk | ||
``` | ||
|
||
Windows builds everything at once. We are aware that our build system needs some love. | ||
|
||
For example, to build the OpenSSL option, run the following script: | ||
|
||
```sh | ||
make -C openssl -f posix.mk pubnub_sync.a | ||
``` | ||
|
||
:warning: If you choose `openssl`, ensure that your OpenSSL library headers match the Unreal ones! | ||
|
||
3. Adjust `PubNubModule/PubNubModule.Build.cs` with selected options by changing `option`, `architecture` and `implementation` with the same values you used for compilation. | ||
|
||
> This is a temporary solution. We are aware that our build system needs some love. | ||
|
||
For example: | ||
|
||
```csharp | ||
private readonly string Option = "openssl"; // posix, windows, openssl | ||
private readonly string Architecture = "posix"; // posix, windows | ||
private readonly string string Implementation = "sync"; // sync, callback | ||
``` | ||
|
||
4. Finally, import the module into your project as follows: | ||
|
||
- `<UnrealProject>.Target.cs` and `<UnrealProject>Editor.Target.cs` | ||
|
||
```csharp | ||
public class <UnrealProject>[Editor]Target : TargetRules | ||
{ | ||
public <UnrealProject>[Editor]Target (TargetInfo Target) : base(Target) | ||
{ | ||
//... | ||
ExtraModuleNames.Add("PubNubModule"); | ||
} | ||
} | ||
``` | ||
|
||
- `<UnrealProject>.uproject` | ||
|
||
```json | ||
{ | ||
//... | ||
"Modules": [ | ||
//... | ||
{ | ||
"Name": "PubNubModule", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
} | ||
], | ||
//... | ||
} | ||
``` | ||
|
||
Generate the project files using your IDE of choice and you are ready to go! | ||
|
||
## Usage | ||
|
||
1. Make PubNub discoverable in the module you want to use PubNub in by modifying the `<Module>.Build.cs` file: | ||
|
||
```csharp | ||
public class <Module> : ModuleRules | ||
{ | ||
public <Module>(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
//... | ||
PrivateDependencyModuleNames.Add("PubNubModule"); | ||
} | ||
} | ||
``` | ||
|
||
2. Import the `PubNub.h` header into your files as follows: | ||
|
||
```cpp | ||
#include "PubNub.h" | ||
``` | ||
|
||
> Note that you don't have to wrap it with `THIRD_PARTY_INCLUDES_START` and `THIRD_PARTY_INCLUDES_END` because we've done that for you. | ||
|
||
Good luck with your project! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ | ||
#if !defined INC_PUBNUB_CORE | ||
#define INC_PUBNUB_CORE | ||
|
||
extern "C" { | ||
|
||
#include "../core/pubnub_api_types.h" | ||
#include "../core/pubnub_assert.h" | ||
#include "../core/pubnub_helper.h" | ||
#include "../lib/pb_deprecated.h" | ||
#include "../core/pubnub_alloc.h" | ||
#include "../core/pubnub_pubsubapi.h" | ||
#include "../core/pubnub_coreapi.h" | ||
#include "../core/pubnub_coreapi_ex.h" | ||
#include "../core/pubnub_generate_uuid.h" | ||
#include "../core/pubnub_blocking_io.h" | ||
#include "../core/pubnub_ssl.h" | ||
#include "../core/pubnub_timers.h" | ||
#include "../core/pubnub_helper.h" | ||
#include "../core/pubnub_free_with_timeout.h" | ||
#include "../core/pubnub_ntf_sync.h" | ||
#if defined(PUBNUB_CALLBACK_API) | ||
#include "../core/pubnub_ntf_callback.h" | ||
#endif | ||
#if PUBNUB_PROXY_API | ||
#include "../core/pubnub_proxy.h" | ||
#endif | ||
#if PUBNUB_USE_SUBSCRIBE_V2 | ||
#include "../core/pubnub_subscribe_v2.h" | ||
#endif | ||
#if PUBNUB_CRYPTO_API | ||
#include "../core/pubnub_crypto.h" | ||
#endif | ||
#if PUBNUB_USE_ADVANCED_HISTORY | ||
#include "../core/pubnub_advanced_history.h" | ||
#endif | ||
#if PUBNUB_USE_FETCH_HISTORY | ||
#include "../core/pubnub_fetch_history.h" | ||
#endif | ||
#if PUBNUB_USE_OBJECTS_API | ||
#include "../core/pubnub_objects_api.h" | ||
#define MAX_INCLUDE_DIMENSION 100 | ||
#define MAX_ELEM_LENGTH 30 | ||
#endif | ||
#if PUBNUB_USE_ACTIONS_API | ||
#include "../core/pubnub_actions_api.h" | ||
#endif | ||
#if PUBNUB_USE_GRANT_TOKEN_API | ||
#include "../core/pubnub_grant_token_api.h" | ||
#endif | ||
#if PUBNUB_USE_REVOKE_TOKEN_API | ||
#include "../core/pubnub_revoke_token_api.h" | ||
#endif | ||
#include "../core/pubnub_auto_heartbeat.h" | ||
|
||
} | ||
|
||
#endif // !defined INC_PUBNUB_CORE |