UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StompClient.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "IStompClient.h"
7#include "Containers/Ticker.h"
8
9#if WITH_STOMP
10
11#include "IStompClient.h"
12#include "IWebSocket.h"
13
14class Error;
15
16class FStompClient
17 : public IStompClient
18 , public FTSTickerObjectBase
19 , public TSharedFromThis<FStompClient>
20{
21public:
22
23 virtual ~FStompClient();
24
25 // FTSTickerObjectBase
26 virtual bool Tick(float DeltaTime) override;
27
28 // IStompClient
29
36 virtual void Connect(const FStompHeader& Header=FStompHeader()) override;
37
43 virtual void Disconnect(const FStompHeader& Header=FStompHeader()) override;
44
48 virtual bool IsConnected() const override;
49
53 virtual FStompSubscriptionId Subscribe(const FString& Destination, const FStompSubscriptionEvent& EventCallback, const FStompRequestCompleted& CompletionCallback = FStompRequestCompleted()) override;
54
58 virtual void Unsubscribe(FStompSubscriptionId Subscription, const FStompRequestCompleted& CompletionCallback = FStompRequestCompleted()) override;
59
63 virtual void Send(const FString& Destination, const FStompBuffer& Body, const FStompHeader& Header=FStompHeader(), const FStompRequestCompleted& CompletionCallback = FStompRequestCompleted()) override;
64
69 DECLARE_DERIVED_EVENT(FStompClient, IStompClient::FStompClientConnectedEvent, FStompClientConnectedEvent);
70 virtual FStompClientConnectedEvent& OnConnected() override
71 {
72 return ConnectedEvent;
73 }
74
79 DECLARE_DERIVED_EVENT(FStompClient, IStompClient::FStompClientConnectionErrorEvent, FStompClientConnectionErrorEvent);
81 {
83 }
84
89 DECLARE_DERIVED_EVENT(FStompClient, IStompClient::FStompClientErrorEvent, FStompClientErrorEvent);
90 virtual FStompClientErrorEvent& OnError() override
91 {
92 return ErrorEvent;
93 }
94
99 DECLARE_DERIVED_EVENT(FStompClient, IStompClient::FStompClientClosedEvent, FStompClientClosedEvent);
100 virtual FStompClientClosedEvent& OnClosed() override
101 {
102 return ClosedEvent;
103 }
104private:
105 FStompClient(const FString& Url, const FTimespan& InPingInterval, const FTimespan& InPongInterval, const FString& OptAuthToken);
106
107 FString MakeId(const class FStompFrame& Frame);
108 void WriteFrame(class FStompFrame& Frame, const FStompRequestCompleted& CompletionCallback=FStompRequestCompleted());
109 void PingServer();
110
111 // WS event handlers
113 void HandleWebSocketConnectionError(const FString& Error);
114 void HandleWebSocketConnectionClosed(int32 Status, const FString& Reason, bool bWasClean);
115 void HandleWebSocketData(const void* Data, SIZE_T Length, SIZE_T BytesRemaining);
116
117 void HandleIncomingFrame(const uint8* Data, SIZE_T Length);
118 void HandleDisconnectCompleted(bool bSuccess, const FString& Error);
119
120
125
129 uint64 IdCounter;
130
132 {
133 FStompRequestCompleted Delegate;
134 FDateTime StartTime;
135 };
137 TMap<FString, FOutstantdingRequestInfo> OutstandingRequests;
138
139 // "ping" is how often we should send an empty heartbeat packets to the server when inactive
140 // "pong" is the minimum how often we should expect activity from the server (counting commands and empty heartbeat frames)
141 FTimespan PingInterval, PongInterval;
145
147
148 bool bIsConnected;
149 FString SessionId;
150 FString ServerString;
151 FString ProtocolVersion;
152
154 enum class EAuthStrategy
155 {
157 None,
158
161
164 };
165
166 EAuthStrategy AuthStrategy = EAuthStrategy::None;
167
168 friend class FStompModule;
169 friend class FStompMessage;
170
171};
172
173#endif
bool bSuccess
Definition ConvexDecomposition3.cpp:819
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DERIVED_EVENT(OwningType, BaseTypeEvent, EventName)
Definition Delegate.h:231
TMap< FName, FString > FStompHeader
Definition IStompClient.h:9
FString FStompSubscriptionId
Definition IStompClient.h:8
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition StompModule.h:17
Definition Ticker.h:137
Definition IStompClient.h:16
virtual FStompClientClosedEvent & OnClosed()=0
virtual void Unsubscribe(FStompSubscriptionId Subscription, const FStompRequestCompleted &CompletionCallback=FStompRequestCompleted())=0
virtual FStompClientErrorEvent & OnError()=0
virtual FStompClientConnectionErrorEvent & OnConnectionError()=0
virtual FStompClientConnectedEvent & OnConnected()=0
virtual FStompSubscriptionId Subscribe(const FString &Destination, const FStompSubscriptionEvent &EventCallback, const FStompRequestCompleted &CompletionCallback=FStompRequestCompleted())=0
virtual bool IsConnected() const =0
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
Definition DateTime.h:76
Definition Timespan.h:76