27#include "CoreMinimal.h"
41 bError = OtherValue.bError;
42 ErrorMessage = OtherValue.ErrorMessage;
47 bError = MoveTemp(OtherValue.bError);
48 ErrorMessage = MoveTemp(OtherValue.ErrorMessage);
54 bError = OtherValue.bError;
55 ErrorMessage = OtherValue.ErrorMessage;
62 bError = MoveTemp(OtherValue.bError);
63 ErrorMessage = MoveTemp(OtherValue.ErrorMessage);
94 Result.ErrorMessage = ErrorMessage;
102 FString ErrorMessage;
168 virtual FOnMethodInvocation&
On(
const FString& EventName) = 0;
180 virtual FOnMethodCompletion&
Invoke(
const FString& EventName,
const TArray<FSignalRValue>& InArguments = TArray<FSignalRValue>()) = 0;
192 template <
typename... ArgTypes>
193 FORCEINLINE FOnMethodCompletion&
Invoke(
const FString& EventName, ArgTypes... Arguments)
195 static_assert(TAnd<TIsConstructible<FSignalRValue, ArgTypes>...>::Value,
"Invalid argument type passed to IHubConnection::Invoke");
196 return Invoke(EventName, TArray<FSignalRValue> { MoveTemp(Arguments)... });
205 virtual void Send(
const FString& EventName,
const TArray<FSignalRValue>& InArguments = TArray<FSignalRValue>()) = 0;
213 template <
typename... ArgTypes>
214 FORCEINLINE
void Send(
const FString& EventName, ArgTypes... Arguments)
216 static_assert(TAnd<TIsConstructible<FSignalRValue, ArgTypes>...>::Value,
"Invalid argument type passed to IHubConnection::Send");
217 Send(EventName, TArray<FSignalRValue> { MoveTemp(Arguments)... });
TSharedPtr< IHubConnection > IHubConnectionPtr
Definition IHubConnection.h:224
Represents the result of a SignalR method invocation, containing either a value or error information.
Definition IHubConnection.h:34
FORCEINLINE bool HasError() const
Checks if the invoke result contains an error.
Definition IHubConnection.h:72
FORCEINLINE const FString & GetErrorMessage() const
Definition IHubConnection.h:78
FSignalRInvokeResult(const FSignalRValue &Value)
Definition IHubConnection.h:37
FSignalRInvokeResult(FSignalRInvokeResult &&OtherValue) noexcept
Definition IHubConnection.h:45
static FORCEINLINE FSignalRInvokeResult Error(const FString &ErrorMessage)
Creates an error result with the specified message.
Definition IHubConnection.h:90
FSignalRInvokeResult & operator=(const FSignalRInvokeResult &OtherValue)
Definition IHubConnection.h:51
FSignalRInvokeResult & operator=(FSignalRInvokeResult &&OtherValue) noexcept
Definition IHubConnection.h:59
friend struct FSignalRInvokeResultWrapper
Definition IHubConnection.h:35
FSignalRInvokeResult(const FSignalRInvokeResult &OtherValue)
Definition IHubConnection.h:39
FSignalRValue()
Create an object representing a EValueType::Null value.
Definition SignalRValue.h:53
FSignalRValue & operator=(const FSignalRValue &OtherValue)
Copies an existing value.
Definition SignalRValue.h:267
Interface for a SignalR hub connection that enables real-time communication with a SignalR server.
Definition IHubConnection.h:110
virtual FOnHubConnectedEvent & OnConnected()=0
Gets the event that is triggered when the connection is successfully established.
virtual FHubConnectionClosedEvent & OnClosed()=0
Gets the event that is triggered when the connection is closed.
FORCEINLINE void Send(const FString &EventName, ArgTypes... Arguments)
Templated version of Send that converts arguments to FSignalRValue automatically.
Definition IHubConnection.h:214
virtual void Start()=0
Starts the connection to the SignalR hub.
virtual void Send(const FString &EventName, const TArray< FSignalRValue > &InArguments=TArray< FSignalRValue >())=0
Sends a message to a hub method on the server without waiting for a response.
virtual ~IHubConnection()
Definition IHubConnection.cpp:27
DECLARE_EVENT(IHubConnection, FOnHubConnectedEvent)
Delegate called when a connection has been established successfully.
DECLARE_EVENT_OneParam(IHubConnection, FOnHubConnectionErrorEvent, const FString &)
Delegate called when a connection could not be established.
virtual FOnMethodCompletion & Invoke(const FString &EventName, const TArray< FSignalRValue > &InArguments=TArray< FSignalRValue >())=0
Invokes a hub method on the server with the specified arguments and waits for a response.
virtual FOnMethodInvocation & On(const FString &EventName)=0
Registers a callback for a specific hub method invocation from the server.
virtual void Stop()=0
Stops the connection to the SignalR hub.
DECLARE_DELEGATE_OneParam(FOnMethodCompletion, const FSignalRInvokeResult &)
FORCEINLINE FOnMethodCompletion & Invoke(const FString &EventName, ArgTypes... Arguments)
Templated version of Invoke that converts arguments to FSignalRValue automatically.
Definition IHubConnection.h:193
DECLARE_DELEGATE_OneParam(FOnMethodInvocation, const TArray< FSignalRValue > &)
virtual FOnHubConnectionErrorEvent & OnConnectionError()=0
Gets the event that is triggered when a connection error occurs.
DECLARE_EVENT(IHubConnection, FHubConnectionClosedEvent)
Delegate called when a web socket connection has been closed.