UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
VoxtaApiResponseHandler.h
Go to the documentation of this file.
1// Copyright(c) 2025 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "VoxtaDefines.h"
7
8class FSignalRValue;
24
33{
34#pragma region public API
35public:
39 static const TSet<FString> IGNORED_MESSAGE_TYPES;
40
47 static TUniquePtr<ServerResponseBase> GetResponseData(
48 const TMap<FString, FSignalRValue>& serverResponseData);
49#pragma endregion
50
51#pragma region VoxtaServer response deserialize handlers
52private:
56 static const TMap<FString, TFunction<TUniquePtr<ServerResponseBase>(const TMap<FString, FSignalRValue>&)>> HANDLERS;
57
59 static TUniquePtr<ServerResponseWelcome> GetWelcomeResponse(
60 const TMap<FString, FSignalRValue>& serverResponseData);
61
63 static TUniquePtr<ServerResponseCharacterList> GetCharacterListLoadedResponse(
64 const TMap<FString, FSignalRValue>& serverResponseData);
65
67 static TUniquePtr<ServerResponseContextUpdated> GetContextUpdatedResponse(
68 const TMap<FString, FSignalRValue>& serverResponseData);
69
71 static TUniquePtr<ServerResponseChatStarted> GetChatStartedResponse(
72 const TMap<FString, FSignalRValue>& serverResponseData);
73
75 static TUniquePtr<ServerResponseChatMessageStart> GetReplyStartResponse(
76 const TMap<FString, FSignalRValue>& serverResponseData);
77
79 static TUniquePtr<ServerResponseChatMessageChunk> GetReplyChunkResponse(
80 const TMap<FString, FSignalRValue>& serverResponseData);
81
83 static TUniquePtr<ServerResponseChatMessageEnd> GetReplyEndResponse(
84 const TMap<FString, FSignalRValue>& serverResponseData);
85
87 static TUniquePtr<ServerResponseChatMessageCancelled> GetReplyCancelledResponse(
88 const TMap<FString, FSignalRValue>& serverResponseData);
89
91 static TUniquePtr<ServerResponseChatUpdate> GetChatUpdateResponse(
92 const TMap<FString, FSignalRValue>& serverResponseData);
93
95 static TUniquePtr<ServerResponseChatClosed> GetChatClosedResponse(
96 const TMap<FString, FSignalRValue>& serverResponseData);
97
99 static TUniquePtr<ServerResponseSpeechTranscription> GetSpeechRecognitionPartial(
100 const TMap<FString, FSignalRValue>& serverResponseData);
101
103 static TUniquePtr<ServerResponseSpeechTranscription> GetSpeechRecognitionEnd(
104 const TMap<FString, FSignalRValue>& serverResponseData);
105
107 static TUniquePtr<ServerResponseError> GetErrorResponse(
108 const TMap<FString, FSignalRValue>& serverResponseData);
109
111 static TUniquePtr<ServerResponseChatSessionError> GetChatSessionErrorResponse(
112 const TMap<FString, FSignalRValue>& serverResponseData);
113
115 static TUniquePtr<ServerResponseConfiguration> GetConfigurationResponse(
116 const TMap<FString, FSignalRValue>& serverResponseData);
117
123 static void ProcessContextData(const TMap<FString, FSignalRValue>& contextMainObject, FString& outContextValue);
124
128 template<typename T>
129 static TUniquePtr<ServerResponseBase> WrapHandler(TUniquePtr<T>(*handler)(const TMap<FString, FSignalRValue>&),
130 const TMap<FString, FSignalRValue>& data)
131 {
132 return handler(data);
133 }
134#pragma endregion
135
136private:
138 static FGuid GetStringAsGuid(const FSignalRValue& input);
139
141 static FGuid GetStringAsGuid(const FString& input);
142};
Represents a value that can be sent to or received from a SignalR hub.
Definition SignalRValue.h:34
VoxtaApiResponseHandler Stateless utility class for deserializing and mapping raw SignalR responses f...
Definition VoxtaApiResponseHandler.h:33
static TUniquePtr< ServerResponseBase > GetResponseData(const TMap< FString, FSignalRValue > &serverResponseData)
Deserialize a SignalR response from the VoxtaServer into the corresponding ServerResponseBase-derived...
Definition VoxtaApiResponseHandler.cpp:55
static const TSet< FString > IGNORED_MESSAGE_TYPES
Set of message types that we could receive from VoxtaServer but are considered safe to ignore and req...
Definition VoxtaApiResponseHandler.h:22
ServerResponseBase Abstract read-only data struct that all responses from the VoxtaServer derive from...
Definition ServerResponseBase.h:15
ServerResponseCharacterList Read-only data struct containing the relevant data of the 'charactersList...
Definition ServerResponseCharacterList.h:15
ServerResponseChatClosed Read-only data struct containing the relevant data of the 'chatClosed' respo...
Definition ServerResponseChatClosed.h:14
Read-only data struct containing the relevant data of the 'replyCancelled' response from the VoxtaSer...
Definition ServerResponseChatMessageCancelled.h:12
ServerResponseChatMessageChunk Read-only data struct containing the relevant data of the 'replyChunk'...
Definition ServerResponseChatMessageChunk.h:14
ServerResponseChatMessageEnd Read-only data struct containing the relevant data of the 'replyEnd' res...
Definition ServerResponseChatMessageEnd.h:14
ServerResponseChatMessageStart Read-only data struct containing the relevant data of the 'replyStart'...
Definition ServerResponseChatMessageStart.h:14
ServerResponseChatSessionError Read-only data struct containing the relevant data of the 'chatSession...
Definition ServerResponseChatSessionError.h:14
ServerResponseChatStarted Read-only data struct containing the relevant data of the 'chatStarted' res...
Definition ServerResponseChatStarted.h:15
ServerResponseChatUpdate Read-only data struct containing the relevant data of the 'update' response ...
Definition ServerResponseChatUpdate.h:14
ServerResponseConfiguration Read-only data struct containing the relevant data of the 'configuration'...
Definition ServerResponseConfiguration.h:15
ServerResponseContextUpdated Read-only data struct containing the relevant data of the 'ContextUpdate...
Definition ServerResponseContextUpdated.h:14
ServerResponseError Read-only data struct containing the relevant data of the 'error' response from t...
Definition ServerResponseError.h:14
ServerResponseSpeechTranscription Read-only data struct containing the relevant data of the 'SpeechTr...
Definition ServerResponseSpeechTranscription.h:14
ServerResponseWelcome Read-only data struct containing the relevant data of the 'welcome' response fr...
Definition ServerResponseWelcome.h:15