UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
IHubProtocol.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2020-2022 Frozen Storm Interactive, Yoann Potinet
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#pragma once
26
27#include "CoreMinimal.h"
28#include "MessageType.h"
29#include "SignalRValue.h"
30
36{
37protected:
39 MessageType(InMessageType)
40 {}
41
42public:
43 virtual ~FHubMessage() {}
44
46};
47
53{
54protected:
55 FBaseInvocationMessage(const FString& InInvocationId, ESignalRMessageType InMessageType) : FHubMessage(InMessageType),
56 InvocationId(InInvocationId)
57 {}
58
59public:
60 const FString InvocationId;
61};
62
68{
69 FInvocationMessage(const FString& InInvocationId, const FString& InTarget, const TArray<FSignalRValue>& InArgs, const TArray<FString>& InStreamIds = TArray<FString>()) :
71 Target(InTarget),
72 Arguments(InArgs),
73 StreamIds(InStreamIds)
74 {}
75
76 FInvocationMessage(FString&& InInvocationId, FString&& InTarget, TArray<FSignalRValue>&& InArgs, TArray<FString>&& InStreamIds = TArray<FString>()) :
77 FBaseInvocationMessage(MoveTemp(InInvocationId), ESignalRMessageType::Invocation),
78 Target(MoveTemp(InTarget)),
79 Arguments(MoveTemp(InArgs)),
80 StreamIds(MoveTemp(InStreamIds))
81 {}
82
83 FString Target;
84 TArray<FSignalRValue> Arguments;
85 TArray<FString> StreamIds;
86};
87
93{
94 FCompletionMessage(const FString& InInvocationId, const FString& InError, const FSignalRValue& InResult, bool InHasResult) :
96 Error(InError),
97 HasResult(InHasResult),
98 Result(InResult)
99 {}
100
101 FCompletionMessage(FString&& InInvocationId, FString&& InError, FSignalRValue&& InResult, bool InHasResult) :
103 Error(InError),
104 HasResult(InHasResult),
105 Result(InResult)
106 {}
107
108 FString Error;
111};
112
121
127{
130
131 TOptional<FString> Error;
132 TOptional<bool> bAllowReconnect;
133};
134
140{
141public:
142 virtual ~IHubProtocol();
143
149 virtual FName Name() const = 0;
150
156 virtual int Version() const = 0;
157
165 virtual FString SerializeMessage(const FHubMessage*) const = 0;
166
174 virtual TArray<TSharedPtr<FHubMessage>> ParseMessages(const FString&) const = 0;
175};
ESignalRMessageType
Enumeration of SignalR message types.
Definition MessageType.h:34
@ Completion
Definition MessageType.h:37
@ Ping
Definition MessageType.h:40
@ Close
Definition MessageType.h:41
@ Invocation
Definition MessageType.h:35
Represents a value that can be sent to or received from a SignalR hub.
Definition SignalRValue.h:34
Interface for SignalR hub protocol implementations.
Definition IHubProtocol.h:140
virtual FString SerializeMessage(const FHubMessage *) const =0
Serializes a hub message to a string.
virtual TArray< TSharedPtr< FHubMessage > > ParseMessages(const FString &) const =0
Parses a string containing one or more serialized hub messages.
virtual FName Name() const =0
Gets the name of the protocol.
virtual int Version() const =0
Gets the version of the protocol.
virtual ~IHubProtocol()
Definition IHubProtocol.cpp:27
const FString InvocationId
Definition IHubProtocol.h:60
FBaseInvocationMessage(const FString &InInvocationId, ESignalRMessageType InMessageType)
Definition IHubProtocol.h:55
TOptional< FString > Error
Definition IHubProtocol.h:131
FCloseMessage()
Definition IHubProtocol.h:128
TOptional< bool > bAllowReconnect
Definition IHubProtocol.h:132
FString Error
Definition IHubProtocol.h:108
bool HasResult
Definition IHubProtocol.h:109
FSignalRValue Result
Definition IHubProtocol.h:110
FCompletionMessage(FString &&InInvocationId, FString &&InError, FSignalRValue &&InResult, bool InHasResult)
Definition IHubProtocol.h:101
FCompletionMessage(const FString &InInvocationId, const FString &InError, const FSignalRValue &InResult, bool InHasResult)
Definition IHubProtocol.h:94
Base message structure for SignalR hub communication.
Definition IHubProtocol.h:36
FHubMessage(ESignalRMessageType InMessageType)
Definition IHubProtocol.h:38
const ESignalRMessageType MessageType
Definition IHubProtocol.h:45
virtual ~FHubMessage()
Definition IHubProtocol.h:43
FInvocationMessage(const FString &InInvocationId, const FString &InTarget, const TArray< FSignalRValue > &InArgs, const TArray< FString > &InStreamIds=TArray< FString >())
Definition IHubProtocol.h:69
TArray< FString > StreamIds
Definition IHubProtocol.h:85
FString Target
Definition IHubProtocol.h:83
TArray< FSignalRValue > Arguments
Definition IHubProtocol.h:84
FInvocationMessage(FString &&InInvocationId, FString &&InTarget, TArray< FSignalRValue > &&InArgs, TArray< FString > &&InStreamIds=TArray< FString >())
Definition IHubProtocol.h:76
FPingMessage()
Definition IHubProtocol.h:118