Files
UnrealEngineUWP/Engine/Source/Developer/TargetPlatform/Public/Interfaces/ITargetDeviceSocket.h
Wojciech Krywult 7b5537cc26 CookOnTheFly (platform protocol): Editor: Added support of the platform-specific transport communication protocols to the editor and use it in the cooking server.
This change allows the cooking server to communicate with clients using platform-specific communication protocols instead of TCP (the default).

This new mode is activated by adding '-platformprotocol' command-line parameter when starting the cooking server (in addition to the usual '-cookonthefly').

The new functionality is included in FNetworkFileServerPlatformProtocol, which is a variant of the preexisting FNetworkFileServer but using ITargetDevice/ITargetDeviceSocket interfaces instead of traditional sockets.

Direct communication with targets is only supported on some platforms, which can be checked by calling ITargetPlatform::SupportsFeature(ETargetPlatformFeatures::DirectDataExchange).

#rb jeff.newquist
#preflight 62166a4237178b0175af6269

[CL 19094838 by Wojciech Krywult in ue5-main branch]
2022-02-23 12:54:09 -05:00

66 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* Interface for target device sockets.
*
* This interface provides an abstraction for communicating with processes running on the target.
*/
class ITargetDeviceSocket
{
public:
/**
* Send data to a connected process on the target device.
*
* This is a blocking operation and it will return only after the whole buffer
* has been sent or an error occurs (e.g. the target disconnects).
*
* False return value typically indicates that the remote peer has closed the connection
* on their side. If it happens, this socket should be closed as well.
*
* @param Data Buffer containing data to be sent (.
* @param BytesToSend The number of bytes from Data that are to be sent.
* @return true if communication was successful, false otherwise.
*
* @see IHostDevice::OpenConnection, IHostDevice::CloseConnection
*/
virtual bool Send(const void* Data, uint64 BytesToSend) = 0;
/**
* Receive data from a connected process on the target device.
*
* This is a blocking operation and it will return only after the expected amount
* of data has been received or an error occurs (e.g. the target disconnects).
*
* False return value typically indicates that the remote peer has closed the connection
* on their side. If it happens, this socket should be closed as well.
*
* @param Data Target buffer for the data to receive (it has to be large enough to store BytesToReceive).
* @param BytesToReceive The number of bytes to receive and store in Data.
* @return true if communication was successful, false otherwise.
*
* @see IHostDevice::OpenConnection, IHostDevice::CloseConnection
*/
virtual bool Receive(void* Data, uint64 BytesToReceive) = 0;
/**
* Returns true if this socket is actually connected to another peer and is ready to send/receive data.
*/
virtual bool Connected() const = 0;
public:
/** Virtual destructor. */
virtual ~ITargetDeviceSocket() { }
};
// Type definition for shared references to instances of IPlatformHostSocket.
typedef TSharedRef<ITargetDeviceSocket, ESPMode::ThreadSafe> ITargetDeviceSocketRef;
// Type definition for shared pointers to instances of IPlatformHostSocket.
typedef TSharedPtr<ITargetDeviceSocket, ESPMode::ThreadSafe> ITargetDeviceSocketPtr;