Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Sep 19, 2024
1 parent 806b069 commit dee89a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
9 changes: 6 additions & 3 deletions include/aws/iot/MqttRequestResponseClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ namespace Aws

using UnmodeledResultHandler = std::function<void(UnmodeledResult &&)>;

template<typename T>
struct AWS_CRT_CPP_API StreamingOperationOptions
{
SubscriptionStatusEventHandler subscriptionStatusEventHandler;

std::function<void(T &&)> streamHandler;
};

struct AWS_CRT_CPP_API StreamingOperationOptionsInternal
Expand All @@ -184,7 +187,7 @@ namespace Aws
public:
virtual ~IStreamingOperation() = default;

virtual void activate() = 0;
virtual void open() = 0;
};

/**
Expand Down Expand Up @@ -220,12 +223,12 @@ namespace Aws

virtual std::shared_ptr<IStreamingOperation> createStream(const StreamingOperationOptionsInternal &options) = 0;

static IMqttRequestResponseClient *newFrom5(
static std::shared_ptr<IMqttRequestResponseClient> newFrom5(
const Aws::Crt::Mqtt5::Mqtt5Client &protocolClient,
const RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator = Aws::Crt::ApiAllocator());

static IMqttRequestResponseClient *newFrom311(
static std::shared_ptr<IMqttRequestResponseClient> newFrom311(
const Aws::Crt::Mqtt::MqttConnection &protocolClient,
const RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator = Aws::Crt::ApiAllocator());
Expand Down
24 changes: 12 additions & 12 deletions source/iot/MqttRequestResponseClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace Aws
struct aws_event_loop *protocolLoop);
virtual ~StreamingOperationImpl();

void activate();
void open();

void close();

Expand Down Expand Up @@ -129,7 +129,7 @@ namespace Aws
aws_rw_lock_clean_up(&m_lock);
}

void StreamingOperationImpl::activate()
void StreamingOperationImpl::open()
{
{
StreamReadLock rlock(&m_lock, m_protocolLoop);
Expand Down Expand Up @@ -220,10 +220,10 @@ namespace Aws
const StreamingOperationOptionsInternal &options,
struct aws_mqtt_request_response_client *client);

StreamingOperation(const std::shared_ptr<StreamingOperationImpl> &impl);
explicit StreamingOperation(const std::shared_ptr<StreamingOperationImpl> &impl);
virtual ~StreamingOperation();

virtual void activate();
virtual void open();

private:
std::shared_ptr<StreamingOperationImpl> m_impl;
Expand Down Expand Up @@ -267,9 +267,9 @@ namespace Aws
m_impl->close();
}

void StreamingOperation::activate()
void StreamingOperation::open()
{
m_impl->activate();
m_impl->open();
}

//////////////////////////////////////////////////////////
Expand Down Expand Up @@ -417,7 +417,7 @@ namespace Aws
MqttRequestResponseClientImpl *m_impl;
};

IMqttRequestResponseClient *IMqttRequestResponseClient::newFrom5(
std::shared_ptr<IMqttRequestResponseClient> IMqttRequestResponseClient::newFrom5(
const Aws::Crt::Mqtt5::Mqtt5Client &protocolClient,
const RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator)
Expand All @@ -435,18 +435,18 @@ namespace Aws
struct aws_mqtt_request_response_client *rrClient =
aws_mqtt_request_response_client_new_from_mqtt5_client(
allocator, protocolClient.GetUnderlyingHandle(), &rrClientOptions);
if (!rrClient)
if (nullptr == rrClient)
{
Aws::Crt::Delete(clientImpl, clientImpl->getAllocator());
return nullptr;
}

clientImpl->seatClient(rrClient);

return Aws::Crt::New<MqttRequestResponseClient>(allocator, clientImpl);
return Aws::Crt::MakeShared<MqttRequestResponseClient>(allocator, clientImpl);
}

IMqttRequestResponseClient *IMqttRequestResponseClient::newFrom311(
std::shared_ptr<IMqttRequestResponseClient> IMqttRequestResponseClient::newFrom311(
const Aws::Crt::Mqtt::MqttConnection &protocolClient,
const RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator)
Expand All @@ -464,15 +464,15 @@ namespace Aws
struct aws_mqtt_request_response_client *rrClient =
aws_mqtt_request_response_client_new_from_mqtt311_client(
allocator, protocolClient.GetUnderlyingConnection(), &rrClientOptions);
if (!rrClient)
if (nullptr == rrClient)
{
Aws::Crt::Delete(clientImpl, clientImpl->getAllocator());
return nullptr;
}

clientImpl->seatClient(rrClient);

return Aws::Crt::New<MqttRequestResponseClient>(allocator, clientImpl);
return Aws::Crt::MakeShared<MqttRequestResponseClient>(allocator, clientImpl);
}

int MqttRequestResponseClient::submitRequest(
Expand Down

0 comments on commit dee89a3

Please sign in to comment.