67 Socket = FWebSocketsModule::Get().CreateWebSocket(Uri, Protocol);
69 Socket->OnConnected().AddLambda([&]() ->
void {
70 Log(
"Apex websocket connected.");
75 Socket->OnConnectionError().AddLambda([&](
const FString&
Error) ->
void {
76 Error(
"Failed to connect with error: %s", *
Error);
81 Socket->OnClosed().AddLambda([&](int32 StatusCode,
const FString& Reason,
bool bWasClean) ->
void {
82 Log(
"Socket closed with status %d, for reason %s", StatusCode, *Reason);
87 Socket->OnMessage().AddLambda([&](
const FString& Message) ->
void {
89 Log(
"Message received: %s", *Message);
93 Error(
"Unable to parse message.");
97 UVaRestJsonObject* MessageJsonObject = RestSubsystem->DecodeJsonObject(Message);
98 if (MessageJsonObject->HasField(
"auth_code"))
103 if (MessageJsonObject->HasField(
"token"))
109 Socket->OnRawMessage().AddLambda([&](
const void* Data, SIZE_T Size, SIZE_T BytesRemaining) ->
void {
111 Log(
"A raw message was received.");
114 Socket->OnMessageSent().AddLambda([&](
const FString& MessageString) ->
void {
115 Log(
"Apex message sent.");