Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
GenericPlatformHostSocket.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 "Templates/SharedPointer.h"
7
8
9
10/**
11 * Interface for sockets supporting direct communication between the game running
12 * on the target device and a connected PC.
13 *
14 * It represents a custom communication channel and may not be implemented on all platforms.
15 *
16 * It is meant to be used in development ONLY.
17 *
18 * @see IPlatformHostCommunication
19 */
21{
22public:
23
24 /**
25 * Status values returned by Send and Receive members.
26 * @see Send, Receive
27 */
28 enum class EResultNet : uint8
29 {
30 Ok, // Communication successful.
31 ErrorUnknown, // Unknown error.
32 ErrorInvalidArgument, // Incorrect parameters provided to a function (shouldn't happen assuming the socket object is valid).
33 ErrorInvalidConnection, // Incorrect socket id used (shouldn't happen assuming the socket object is valid).
34 ErrorInterrupted, // Data transfer interrupted e.g. a networking issue.
35 ErrorHostNotConnected // Host PC is not connected (not connected yet or has already disconnected).
36 };
37
38 /**
39 * State of the socket determining its ability to send/receive data.
40 * @see GetState
41 */
43 {
44 Unknown, // Default state (shouldn't be returned).
45 Created, // Socket has been created by cannot communicate yet (no host pc connected yet).
46 Connected, // Socket ready for communication.
47 Disconnected, // Host PC has disconnected (no communication possible, socket should be closed).
48 Closed, // Socket has already been closed and shouldn't be used.
49 };
50
51public:
52
53 /**
54 * Send data to the connected host PC (blocking operation).
55 *
56 * @param Buffer Data to be sent.
57 * @param BytesToSend The number of bytes to send.
58 * @return Status value indicating error or success.
59 */
60 virtual EResultNet Send(const void* Buffer, uint64 BytesToSend) = 0;
61
62 /**
63 * Receive data from the connected host PC (blocking operation).
64 *
65 * @param Buffer Data to be sent.
66 * @param BytesToReceive The number of bytes to receive (Buffer has to be large enough).
67 * @return Status value indicating error or success.
68 */
69 virtual EResultNet Receive(void* Buffer, uint64 BytesToReceive) = 0;
70
71 /**
72 * Get the state of the socket (determines if the host pc is connected and communication is possible).
73 */
74 virtual EConnectionState GetState() const = 0;
75
76 /**
77 * Destructor.
78 */
80 {
81 }
82};
83
84
85// Type definition for shared references to instances of IPlatformHostSocket.
87
88// Type definition for shared pointers to instances of IPlatformHostSocket.
TSharedRef< IPlatformHostSocket, ESPMode::ThreadSafe > IPlatformHostSocketRef
TSharedPtr< IPlatformHostSocket, ESPMode::ThreadSafe > IPlatformHostSocketPtr
virtual EResultNet Receive(void *Buffer, uint64 BytesToReceive)=0
virtual EConnectionState GetState() const =0
virtual EResultNet Send(const void *Buffer, uint64 BytesToSend)=0