Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
GenericPlatformHostCommunication.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/UnrealString.h"
7#include "GenericPlatform/GenericPlatformHostSocket.h"
8
9
10
11/**
12 * Known custom communication protocols used by the engine.
13 *
14 * These values may be used as ProtocolIndex parameter when calling OpenConnection.
15 *
16 * @see IPlatformHostCommunication::OpenConnection
17 */
19{
20 CookOnTheFly = 0
21};
22
23
24/**
25 * Interface for communication between the game running on the target device and the connected host pc.
26 *
27 * It represents a custom communication channel and may not be implemented on all platforms.
28 *
29 * It is meant to be used in development ONLY.
30 */
32{
33public:
34
35 /**
36 * Initialize the host communication system (done by IPlatformFeaturesModule).
37 */
38 virtual void Initialize() = 0;
39
40 /**
41 * Shutdown the host communication system (done by IPlatformFeaturesModule).
42 */
43 virtual void Shutdown() = 0;
44
45 /**
46 * Check if the host communication system is available and can be used.
47 *
48 * @return True is available, false otherwise.
49 */
50 virtual bool Available() const = 0;
51
52 /**
53 * Open a communication channel with the host PC.
54 *
55 * The connected PC is determined in a platform-dependent way.
56 *
57 * Note that opening a connection does not necessarily mean that the host PC is ready to communicate.
58 * Check the state of the socket before attempting to send/receive data. There can be only one
59 * connection using any given ProtocolIndex. Attempts to use a ProtocolIndex while there is already
60 * a connection using it will fail.
61 *
62 * @param ProtocolIndex Arbitrary 0-based number indicating the communication channel (the same number needs to be used on the host PC).
63 * @param DebugName Name of this communication channel used for diagnostic purposes.
64 * @param Version (optional) Version of the communication protocol (ProtocolIndex) used to verify compatibility with the host PC.
65 * @param MinVersion (optional) Minimum version of the communication protocol (ProtocolIndex) that is supported.
66 * @return Socket object on success, nullptr otherwise.
67 *
68 * @see CloseConnection, IPlatformHostSocket::GetState
69 */
70 virtual IPlatformHostSocketPtr OpenConnection(uint32 ProtocolIndex, const FString& DebugName, uint32 Version = 0, uint32 MinVersion = 0) = 0;
71
72 /**
73 * Close a communication channel previously opened using OpenConnection.
74 * @param Socket Socket object.
75 */
76 virtual void CloseConnection(IPlatformHostSocketPtr Socket) = 0;
77
78 /**
79 * Launch an executable on the connected host PC.
80 * @param BinaryPath Path to the executable on the PC to launch.
81 * @param CmdLine (optional) Command line parameters to pass to the executable.
82 * @return True on success, otherwise false (e.g. no permissions or incorrect executable path).
83 */
84 virtual bool LaunchOnHost(const char* BinaryPath, const char* CmdLine = nullptr) = 0;
85
86 /**
87 * Virtual destructor.
88 */
90 {
91 }
92};
93
94
95/**
96 * Generic implementation of IPlatformHostCommunication.
97 */
99{
100public:
101
102 virtual void Initialize() override
103 {
104 }
105
106 virtual void Shutdown() override
107 {
108 }
109
110 virtual bool Available() const override
111 {
112 return false;
113 }
114
115 virtual IPlatformHostSocketPtr OpenConnection(uint32 ProtocolIndex, const FString& DebugName, uint32 Version = 0, uint32 MinVersion = 0) override
116 {
117 return nullptr;
118 }
119
121 {
122 }
123
124 bool LaunchOnHost(const char* BinaryPath, const char* CmdLine = nullptr) override
125 {
126 return false;
127 }
128};
129
130
131/**
132 * Helper RAII type for auto initializing instances derived from IPlatformHostCommunication.
133 */
134template <typename T>
136{
138 {
140 }
141
143 {
145 }
146
148 {
149 return HostCommunication;
150 }
151
153};
EHostProtocol
Definition Enums.h:33057
TSharedPtr< IPlatformHostSocket, ESPMode::ThreadSafe > IPlatformHostSocketPtr
void CloseConnection(IPlatformHostSocketPtr Socket) override
virtual IPlatformHostSocketPtr OpenConnection(uint32 ProtocolIndex, const FString &DebugName, uint32 Version=0, uint32 MinVersion=0) override
bool LaunchOnHost(const char *BinaryPath, const char *CmdLine=nullptr) override
virtual bool LaunchOnHost(const char *BinaryPath, const char *CmdLine=nullptr)=0
virtual IPlatformHostSocketPtr OpenConnection(uint32 ProtocolIndex, const FString &DebugName, uint32 Version=0, uint32 MinVersion=0)=0
virtual bool Available() const =0
virtual void Initialize()=0
virtual void Shutdown()=0
virtual void CloseConnection(IPlatformHostSocketPtr Socket)=0