AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
ChatHandler.h
1
6#pragma once
7#include <aws/core/utils/HashingUtils.h>
8#include <aws/core/utils/event/EventStreamHandler.h>
9#include <aws/core/client/AWSError.h>
10#include <aws/qbusiness/QBusiness_EXPORTS.h>
11#include <aws/qbusiness/QBusinessErrors.h>
12
13#include <aws/qbusiness/model/ChatInitialResponse.h>
14#include <aws/qbusiness/model/TextOutputEvent.h>
15#include <aws/qbusiness/model/MetadataEvent.h>
16#include <aws/qbusiness/model/ActionReviewEvent.h>
17#include <aws/qbusiness/model/FailedAttachmentEvent.h>
18#include <aws/qbusiness/model/AuthChallengeRequestEvent.h>
19
20namespace Aws
21{
22namespace QBusiness
23{
24namespace Model
25{
26 enum class ChatEventType
27 {
35 };
36
38 {
39 typedef std::function<void(const ChatInitialResponse&)> ChatInitialResponseCallback;
40 typedef std::function<void(const ChatInitialResponse&, const Utils::Event::InitialResponseType)> ChatInitialResponseCallbackEx;
41 typedef std::function<void(const TextOutputEvent&)> TextOutputEventCallback;
42 typedef std::function<void(const MetadataEvent&)> MetadataEventCallback;
43 typedef std::function<void(const ActionReviewEvent&)> ActionReviewEventCallback;
44 typedef std::function<void(const FailedAttachmentEvent&)> FailedAttachmentEventCallback;
45 typedef std::function<void(const AuthChallengeRequestEvent&)> AuthChallengeRequestEventCallback;
46 typedef std::function<void(const Aws::Client::AWSError<QBusinessErrors>& error)> ErrorCallback;
47
48 public:
49 AWS_QBUSINESS_API ChatHandler();
50 AWS_QBUSINESS_API ChatHandler& operator=(const ChatHandler&) = default;
51
52 AWS_QBUSINESS_API virtual void OnEvent() override;
53
55
61 inline void SetInitialResponseCallbackEx(const ChatInitialResponseCallbackEx& callback) { m_onInitialResponse = callback; }
65 inline void SetInitialResponseCallback(const ChatInitialResponseCallback& noArgCallback)
66 {
67 m_onInitialResponse = [noArgCallback](const ChatInitialResponse& rs, const Utils::Event::InitialResponseType) { return noArgCallback(rs); };
68 }
70 inline void SetTextOutputEventCallback(const TextOutputEventCallback& callback) { m_onTextOutputEvent = callback; }
71 inline void SetMetadataEventCallback(const MetadataEventCallback& callback) { m_onMetadataEvent = callback; }
72 inline void SetActionReviewEventCallback(const ActionReviewEventCallback& callback) { m_onActionReviewEvent = callback; }
73 inline void SetFailedAttachmentEventCallback(const FailedAttachmentEventCallback& callback) { m_onFailedAttachmentEvent = callback; }
74 inline void SetAuthChallengeRequestEventCallback(const AuthChallengeRequestEventCallback& callback) { m_onAuthChallengeRequestEvent = callback; }
75 inline void SetOnErrorCallback(const ErrorCallback& callback) { m_onError = callback; }
76
77 inline ChatInitialResponseCallbackEx& GetInitialResponseCallbackEx() { return m_onInitialResponse; }
78
79 private:
80 AWS_QBUSINESS_API void HandleEventInMessage();
81 AWS_QBUSINESS_API void HandleErrorInMessage();
82 AWS_QBUSINESS_API void MarshallError(const Aws::String& errorCode, const Aws::String& errorMessage);
83
84 ChatInitialResponseCallbackEx m_onInitialResponse;
85 TextOutputEventCallback m_onTextOutputEvent;
86 MetadataEventCallback m_onMetadataEvent;
87 ActionReviewEventCallback m_onActionReviewEvent;
88 FailedAttachmentEventCallback m_onFailedAttachmentEvent;
89 AuthChallengeRequestEventCallback m_onAuthChallengeRequestEvent;
90 ErrorCallback m_onError;
91 };
92
93namespace ChatEventMapper
94{
95 AWS_QBUSINESS_API ChatEventType GetChatEventTypeForName(const Aws::String& name);
96
98} // namespace ChatEventMapper
99} // namespace Model
100} // namespace QBusiness
101} // namespace Aws
void SetActionReviewEventCallback(const ActionReviewEventCallback &callback)
Definition ChatHandler.h:72
virtual AWS_QBUSINESS_API void OnEvent() override
AWS_QBUSINESS_API ChatHandler & operator=(const ChatHandler &)=default
void SetInitialResponseCallback(const ChatInitialResponseCallback &noArgCallback)
Definition ChatHandler.h:65
void SetAuthChallengeRequestEventCallback(const AuthChallengeRequestEventCallback &callback)
Definition ChatHandler.h:74
void SetFailedAttachmentEventCallback(const FailedAttachmentEventCallback &callback)
Definition ChatHandler.h:73
void SetOnErrorCallback(const ErrorCallback &callback)
Definition ChatHandler.h:75
void SetTextOutputEventCallback(const TextOutputEventCallback &callback)
Definition ChatHandler.h:70
void SetInitialResponseCallbackEx(const ChatInitialResponseCallbackEx &callback)
Definition ChatHandler.h:61
ChatInitialResponseCallbackEx & GetInitialResponseCallbackEx()
Definition ChatHandler.h:77
void SetMetadataEventCallback(const MetadataEventCallback &callback)
Definition ChatHandler.h:71
AWS_QBUSINESS_API ChatEventType GetChatEventTypeForName(const Aws::String &name)
AWS_QBUSINESS_API Aws::String GetNameForChatEventType(ChatEventType value)
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String