UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IWebSocket Class Referenceabstract

#include <IWebSocket.h>

Public Member Functions

virtual ~IWebSocket ()
 
virtual void Connect ()=0
 
virtual void Close (int32 Code=1000, const FString &Reason=FString())=0
 
virtual bool IsConnected ()=0
 
virtual void Send (const FString &Data)=0
 
virtual void Send (const void *Data, SIZE_T Size, bool bIsBinary=false)=0
 
virtual void SetTextMessageMemoryLimit (uint64 TextMessageMemoryLimit)=0
 
 DECLARE_EVENT (IWebSocket, FWebSocketConnectedEvent)
 
virtual FWebSocketConnectedEventOnConnected ()=0
 
 DECLARE_EVENT_OneParam (IWebSocket, FWebSocketConnectionErrorEvent, const FString &)
 
virtual FWebSocketConnectionErrorEventOnConnectionError ()=0
 
 DECLARE_EVENT_ThreeParams (IWebSocket, FWebSocketClosedEvent, int32, const FString &, bool)
 
virtual FWebSocketClosedEventOnClosed ()=0
 
 DECLARE_EVENT_OneParam (IWebSocket, FWebSocketMessageEvent, const FString &)
 
virtual FWebSocketMessageEventOnMessage ()=0
 
 DECLARE_EVENT_ThreeParams (IWebSocket, FWebSocketBinaryMessageEvent, const void *, SIZE_T, bool)
 
virtual FWebSocketBinaryMessageEventOnBinaryMessage ()=0
 
 DECLARE_EVENT_ThreeParams (IWebSocket, FWebSocketRawMessageEvent, const void *, SIZE_T, SIZE_T)
 
virtual FWebSocketRawMessageEventOnRawMessage ()=0
 
 DECLARE_EVENT_OneParam (IWebSocket, FWebSocketMessageSentEvent, const FString &)
 
virtual FWebSocketMessageSentEventOnMessageSent ()=0
 

Constructor & Destructor Documentation

◆ ~IWebSocket()

virtual IWebSocket::~IWebSocket ( )
inlinevirtual

Member Function Documentation

◆ Close()

virtual void IWebSocket::Close ( int32  Code = 1000,
const FString &  Reason = FString() 
)
pure virtual

Close the current connection.

Parameters
CodeNumeric status code explaining why the connection is being closed. Default is 1000. See WebSockets spec for valid codes.
ReasonHuman readable string explaining why the connection is closing.

◆ Connect()

virtual void IWebSocket::Connect ( )
pure virtual

Initiate a client connection to the server. Use this after setting up event handlers or to reconnect after connection errors.

◆ DECLARE_EVENT()

IWebSocket::DECLARE_EVENT ( IWebSocket  ,
FWebSocketConnectedEvent   
)

Delegate called when a web socket connection has been established successfully.

◆ DECLARE_EVENT_OneParam() [1/3]

IWebSocket::DECLARE_EVENT_OneParam ( IWebSocket  ,
FWebSocketConnectionErrorEvent  ,
const FString &   
)

Delegate called when a web socket connection could not be established.

◆ DECLARE_EVENT_OneParam() [2/3]

IWebSocket::DECLARE_EVENT_OneParam ( IWebSocket  ,
FWebSocketMessageEvent  ,
const FString &   
)

Delegate called when a web socket text message has been received. Assumes the payload is encoded as UTF8. For binary data, bind to OnRawMessage instead.

◆ DECLARE_EVENT_OneParam() [3/3]

IWebSocket::DECLARE_EVENT_OneParam ( IWebSocket  ,
FWebSocketMessageSentEvent  ,
const FString &   
)

Delegate called when a web socket text message has been sent. Assume UTF-8 encoding.

◆ DECLARE_EVENT_ThreeParams() [1/3]

IWebSocket::DECLARE_EVENT_ThreeParams ( IWebSocket  ,
FWebSocketBinaryMessageEvent  ,
const void ,
SIZE_T  ,
bool   
)

Delegate called when web socket binary data has been received. bIsLastFragment will be true if it is the last fragment of the current packet.

◆ DECLARE_EVENT_ThreeParams() [2/3]

IWebSocket::DECLARE_EVENT_ThreeParams ( IWebSocket  ,
FWebSocketClosedEvent  ,
int32  ,
const FString &  ,
bool   
)

Delegate called when a web socket connection has been closed.

◆ DECLARE_EVENT_ThreeParams() [3/3]

IWebSocket::DECLARE_EVENT_ThreeParams ( IWebSocket  ,
FWebSocketRawMessageEvent  ,
const void ,
SIZE_T  ,
SIZE_T   
)

Delegate called when any web socket data has been received. May be called multiple times for a message if the message was split into multiple frames. This is called for every web socket fragment. BytesRemaining is the number of bytes left in the current fragment.

◆ IsConnected()

virtual bool IWebSocket::IsConnected ( )
pure virtual

Inquire if this web socket instance is connected to a server.

◆ OnBinaryMessage()

virtual FWebSocketBinaryMessageEvent & IWebSocket::OnBinaryMessage ( )
pure virtual

◆ OnClosed()

virtual FWebSocketClosedEvent & IWebSocket::OnClosed ( )
pure virtual

◆ OnConnected()

virtual FWebSocketConnectedEvent & IWebSocket::OnConnected ( )
pure virtual

◆ OnConnectionError()

virtual FWebSocketConnectionErrorEvent & IWebSocket::OnConnectionError ( )
pure virtual

◆ OnMessage()

virtual FWebSocketMessageEvent & IWebSocket::OnMessage ( )
pure virtual

◆ OnMessageSent()

virtual FWebSocketMessageSentEvent & IWebSocket::OnMessageSent ( )
pure virtual

◆ OnRawMessage()

virtual FWebSocketRawMessageEvent & IWebSocket::OnRawMessage ( )
pure virtual

◆ Send() [1/2]

virtual void IWebSocket::Send ( const FString &  Data)
pure virtual

Transmit data over the connection.

Parameters
Datadata to be sent as a UTF-8 encoded string.

◆ Send() [2/2]

virtual void IWebSocket::Send ( const void Data,
SIZE_T  Size,
bool  bIsBinary = false 
)
pure virtual

Transmit data over the connection.

Parameters
Dataraw binary data to be sent.
Sizenumber of bytes to send.
bIsBinaryset to true to send binary frame to the peer instead of text.

◆ SetTextMessageMemoryLimit()

virtual void IWebSocket::SetTextMessageMemoryLimit ( uint64  TextMessageMemoryLimit)
pure virtual

Optionally change memory limit for receiving UTF-8 text on this socket. Default from config TextMessageMemoryLimit under [WebSockets] or 1MB.

Parameters
TextMessageMemoryLimitnew buffer size upper limit in bytes.

The documentation for this class was generated from the following file: