@@ -47,7 +47,7 @@ namespace Aws
47
47
48
48
/* *
49
49
* A callback prototype that is called upon flushing a message over the wire.
50
- * @param errorCode A non-zero value if an error occured while attempting to flush the message.
50
+ * @param errorCode A non-zero value if an error occured while attempting to flush the message.
51
51
*/
52
52
using OnMessageFlushCallback = std::function<void (int errorCode)>;
53
53
@@ -56,7 +56,7 @@ namespace Aws
56
56
* packet sent out by the client.
57
57
* @return The `MessageAmendment` for the client to use during an attempt to connect.
58
58
*/
59
- using ConnectMessageAmender = std::function<MessageAmendment &(void )>;
59
+ using ConnectMessageAmender = std::function<const MessageAmendment &(void )>;
60
60
61
61
/* *
62
62
* A wrapper around an `aws_event_stream_header_value_pair` object.
@@ -144,25 +144,65 @@ namespace Aws
144
144
};
145
145
146
146
/* *
147
- * Configuration structure holding all options relating to eventstream RPC connection establishment
147
+ * Configuration structure holding all configurations relating to eventstream RPC connection establishment
148
148
*/
149
- struct AWS_EVENTSTREAMRPC_API ClientConnectionOptions final
149
+ class ConnectionConfig
150
150
{
151
- ClientConnectionOptions ();
152
- ClientConnectionOptions (const ClientConnectionOptions &rhs) = default ;
153
- ClientConnectionOptions (ClientConnectionOptions &&rhs) = default ;
154
-
155
- ~ClientConnectionOptions () = default ;
151
+ public:
152
+ ConnectionConfig () noexcept : m_clientBootstrap(nullptr ), m_connectRequestCallback(nullptr ) {}
153
+ Crt::Optional<Crt::String> GetHostName () const noexcept { return m_hostName; }
154
+ Crt::Optional<uint16_t > GetPort () const noexcept { return m_port; }
155
+ Crt::Optional<Crt::Io::SocketDomain> GetSocketDomain () const noexcept { return m_socketDomain; }
156
+ Crt::Optional<Crt::Io::SocketType> GetSocketType () const noexcept { return m_socketType; }
157
+ Crt::Optional<MessageAmendment> GetConnectAmendment () const noexcept { return m_connectAmendment; }
158
+ Crt::Optional<Crt::Io::TlsConnectionOptions> GetTlsConnectionOptions () const noexcept
159
+ {
160
+ return m_tlsConnectionOptions;
161
+ }
162
+ Crt::Io::ClientBootstrap *GetClientBootstrap () const noexcept { return m_clientBootstrap; }
163
+ OnMessageFlushCallback GetConnectRequestCallback () const noexcept { return m_connectRequestCallback; }
164
+ ConnectMessageAmender GetConnectMessageAmender () const noexcept
165
+ {
166
+ if (m_connectAmendment.has_value ())
167
+ {
168
+ return [&](void ) -> const MessageAmendment & { return m_connectAmendment.value (); };
169
+ }
170
+ else
171
+ {
172
+ return nullptr ;
173
+ }
174
+ }
156
175
157
- ClientConnectionOptions &operator =(const ClientConnectionOptions &rhs) = default ;
158
- ClientConnectionOptions &operator =(ClientConnectionOptions &&rhs) = default ;
176
+ void SetHostName (Crt::String hostName) noexcept { m_hostName = hostName; }
177
+ void SetPort (uint16_t port) noexcept { m_port = port; }
178
+ void SetSocketDomain (Crt::Io::SocketDomain socketDomain) noexcept { m_socketDomain = socketDomain; }
179
+ void SetSocketType (Crt::Io::SocketType socketType) noexcept { m_socketType = socketType; }
180
+ void SetConnectAmendment (MessageAmendment connectAmendment) noexcept
181
+ {
182
+ m_connectAmendment = connectAmendment;
183
+ }
184
+ void SetTlsConnectionOptions (Crt::Io::TlsConnectionOptions tlsConnectionOptions) noexcept
185
+ {
186
+ m_tlsConnectionOptions = tlsConnectionOptions;
187
+ }
188
+ void SetClientBootstrap (Crt::Io::ClientBootstrap *clientBootstrap) noexcept
189
+ {
190
+ m_clientBootstrap = clientBootstrap;
191
+ }
192
+ void SetConnectRequestCallback (OnMessageFlushCallback connectRequestCallback) noexcept
193
+ {
194
+ m_connectRequestCallback = connectRequestCallback;
195
+ }
159
196
160
- Crt::Io::ClientBootstrap *Bootstrap;
161
- Crt::Io::SocketOptions SocketOptions;
162
- Crt::Optional<Crt::Io::TlsConnectionOptions> TlsOptions;
163
- Crt::String HostName;
164
- uint16_t Port;
165
- OnMessageFlushCallback ConnectRequestCallback;
197
+ protected:
198
+ Crt::Optional<Crt::String> m_hostName;
199
+ Crt::Optional<uint16_t > m_port;
200
+ Crt::Optional<Crt::Io::SocketDomain> m_socketDomain;
201
+ Crt::Optional<Crt::Io::SocketType> m_socketType;
202
+ Crt::Optional<Crt::Io::TlsConnectionOptions> m_tlsConnectionOptions;
203
+ Crt::Io::ClientBootstrap *m_clientBootstrap;
204
+ Crt::Optional<MessageAmendment> m_connectAmendment;
205
+ OnMessageFlushCallback m_connectRequestCallback;
166
206
};
167
207
168
208
class AWS_EVENTSTREAMRPC_API ConnectionLifecycleHandler
@@ -216,7 +256,7 @@ namespace Aws
216
256
virtual void OnContinuationClosed () = 0;
217
257
};
218
258
219
- enum EventStreamRpcError
259
+ enum EventStreamRpcStatusCode
220
260
{
221
261
EVENT_STREAM_RPC_SUCCESS = 0 ,
222
262
EVENT_STREAM_RPC_NULL_PARAMETER,
@@ -231,7 +271,7 @@ namespace Aws
231
271
232
272
struct RpcError
233
273
{
234
- EventStreamRpcError baseStatus;
274
+ EventStreamRpcStatusCode baseStatus;
235
275
int crtError;
236
276
operator bool () const noexcept { return baseStatus == EVENT_STREAM_RPC_SUCCESS; }
237
277
};
@@ -267,7 +307,7 @@ namespace Aws
267
307
ClientConnection &operator =(ClientConnection &&) noexcept ;
268
308
269
309
std::future<RpcError> Connect (
270
- const ClientConnectionOptions &connectionOptions,
310
+ const ConnectionConfig &connectionOptions,
271
311
ConnectionLifecycleHandler *connectionLifecycleHandler,
272
312
ConnectMessageAmender connectMessageAmender) noexcept ;
273
313
@@ -569,7 +609,6 @@ namespace Aws
569
609
ClientOperation (ClientOperation &&clientOperation) noexcept ;
570
610
std::future<RpcError> Close (OnMessageFlushCallback onMessageFlushCallback = nullptr ) noexcept ;
571
611
std::future<TaggedResult> GetOperationResult () noexcept ;
572
- // virtual bool IsStreaming() = 0;
573
612
574
613
protected:
575
614
std::future<RpcError> Activate (
@@ -582,8 +621,8 @@ namespace Aws
582
621
const OperationModelContext &m_operationModelContext;
583
622
584
623
private:
585
- EventStreamRpcError HandleData (const Crt::String &modelName, const Crt::Optional<Crt::ByteBuf> &payload);
586
- EventStreamRpcError HandleError (
624
+ EventStreamRpcStatusCode HandleData (const Crt::String &modelName, const Crt::Optional<Crt::ByteBuf> &payload);
625
+ EventStreamRpcStatusCode HandleError (
587
626
const Crt::String &modelName,
588
627
const Crt::Optional<Crt::ByteBuf> &payload,
589
628
uint16_t messageFlags);
0 commit comments