Add simple reading to TlsConnection
This patch implements a ReceiveMessage method for TlsConnectionPosix,
that simply checks if bytes are pending and then reads them if so,
reporting any errors that occur.
Change-Id: If9c453cd466c235c502ed16deedac3b7538a6a46
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1816287
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
diff --git a/platform/api/tls_connection.cc b/platform/api/tls_connection.cc
index 0696e4f..ee0258c 100644
--- a/platform/api/tls_connection.cc
+++ b/platform/api/tls_connection.cc
@@ -42,14 +42,14 @@
});
}
-void TlsConnection::OnRead(std::vector<uint8_t> message) {
+void TlsConnection::OnRead(std::vector<uint8_t> block) {
if (!client_) {
return;
}
- task_runner_->PostTask([m = std::move(message), this]() mutable {
+ task_runner_->PostTask([b = std::move(block), this]() mutable {
// TODO(issues/71): |this| may be invalid at this point.
- this->client_->OnRead(this, std::move(m));
+ this->client_->OnRead(this, std::move(b));
});
}
diff --git a/platform/api/tls_connection.h b/platform/api/tls_connection.h
index 1126265..de7faff 100644
--- a/platform/api/tls_connection.h
+++ b/platform/api/tls_connection.h
@@ -33,11 +33,11 @@
virtual void OnWriteUnblocked(TlsConnection* connection) = 0;
// Called when |connection| experiences an error, such as a read error.
- virtual void OnError(TlsConnection* socket, Error error) = 0;
+ virtual void OnError(TlsConnection* connection, Error error) = 0;
- // Called when a |packet| arrives on |socket|.
- virtual void OnRead(TlsConnection* socket,
- std::vector<uint8_t> message) = 0;
+ // Called when a |block| arrives on |connection|.
+ virtual void OnRead(TlsConnection* connection,
+ std::vector<uint8_t> block) = 0;
protected:
virtual ~Client() = default;