summaryrefslogtreecommitdiff
path: root/implementation/endpoints/src/local_client_endpoint_impl.cpp
diff options
context:
space:
mode:
authorDirk Huss <dirk_huss@mentor.com>2015-11-25 15:11:49 +0100
committerDirk Huss <dirk_huss@mentor.com>2015-11-25 15:11:49 +0100
commit78be04b467566633318a277ccd2d968c1c4e46bf (patch)
tree444ef60cfdca2cc80d584f26911fb08b93a034b9 /implementation/endpoints/src/local_client_endpoint_impl.cpp
parent40d4759f262a86bcebaf3a91d9d813f4d6a3ae10 (diff)
downloadvSomeIP-78be04b467566633318a277ccd2d968c1c4e46bf.tar.gz
vSomeIP 2.0.02.0.0
Diffstat (limited to 'implementation/endpoints/src/local_client_endpoint_impl.cpp')
-rw-r--r--implementation/endpoints/src/local_client_endpoint_impl.cpp77
1 files changed, 48 insertions, 29 deletions
diff --git a/implementation/endpoints/src/local_client_endpoint_impl.cpp b/implementation/endpoints/src/local_client_endpoint_impl.cpp
index b465baa..323c414 100644
--- a/implementation/endpoints/src/local_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/local_client_endpoint_impl.cpp
@@ -9,17 +9,17 @@
#include <boost/asio/write.hpp>
#include <vsomeip/defines.hpp>
-#include <vsomeip/logger.hpp>
#include "../include/endpoint_host.hpp"
#include "../include/local_client_endpoint_impl.hpp"
+#include "../../logging/include/logger.hpp"
namespace vsomeip {
local_client_endpoint_impl::local_client_endpoint_impl(
std::shared_ptr< endpoint_host > _host, endpoint_type _remote,
- boost::asio::io_service &_io)
- : local_client_endpoint_base_impl(_host, _remote, _io) {
+ boost::asio::io_service &_io, std::uint32_t _max_message_size)
+ : local_client_endpoint_base_impl(_host, _remote, _io, _max_message_size) {
is_supporting_magic_cookies_ = false;
}
@@ -49,34 +49,22 @@ void local_client_endpoint_impl::connect() {
}
void local_client_endpoint_impl::receive() {
- packet_buffer_ptr_t its_buffer
- = std::make_shared< packet_buffer_t >();
+ receive_buffer_t its_buffer(VSOMEIP_MAX_LOCAL_MESSAGE_SIZE , 0);
socket_.async_receive(
- boost::asio::buffer(*its_buffer),
+ boost::asio::buffer(its_buffer),
std::bind(
&local_client_endpoint_impl::receive_cbk,
std::dynamic_pointer_cast<
local_client_endpoint_impl
>(shared_from_this()),
- its_buffer,
std::placeholders::_1,
std::placeholders::_2
)
);
}
-void local_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
-#if 0
- std::stringstream msg;
- msg << "lce<" << this << ">::sq: ";
- for (std::size_t i = 0; i < _buffer->size(); i++)
- msg << std::setw(2) << std::setfill('0') << std::hex
- << (int)(*_buffer)[i] << " ";
- VSOMEIP_DEBUG << msg.str();
-#endif
-
+void local_client_endpoint_impl::send_queued() {
static byte_t its_start_tag[] = { 0x67, 0x37, 0x6D, 0x07 };
- static byte_t its_end_tag[] = { 0x07, 0x6D, 0x37, 0x67 };
boost::asio::async_write(
socket_,
@@ -85,7 +73,7 @@ void local_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
sizeof(its_start_tag)
),
std::bind(
- &local_client_endpoint_impl::send_tag_cbk,
+ &local_client_endpoint_impl::send_start_tag_cbk,
std::dynamic_pointer_cast<
local_client_endpoint_impl
>(shared_from_this()),
@@ -93,18 +81,36 @@ void local_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
std::placeholders::_2
)
);
+}
+
+void local_client_endpoint_impl::send_queued_data() {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ message_buffer_ptr_t its_buffer = queue_.front();
+ #if 0
+ std::stringstream msg;
+ msg << "lce<" << this << ">::sq: ";
+ for (std::size_t i = 0; i < its_buffer->size(); i++)
+ msg << std::setw(2) << std::setfill('0') << std::hex
+ << (int)(*its_buffer)[i] << " ";
+ VSOMEIP_DEBUG << msg.str();
+ #endif
boost::asio::async_write(
socket_,
- boost::asio::buffer(*_buffer),
+ boost::asio::buffer(*its_buffer),
std::bind(
- &client_endpoint_impl::send_cbk,
- this->shared_from_this(),
- _buffer,
+ &local_client_endpoint_impl::send_queued_data_cbk,
+ std::dynamic_pointer_cast<
+ local_client_endpoint_impl
+ >(shared_from_this()),
std::placeholders::_1,
std::placeholders::_2
)
);
+}
+
+void local_client_endpoint_impl::send_end_tag() {
+ static byte_t its_end_tag[] = { 0x07, 0x6D, 0x37, 0x67 };
boost::asio::async_write(
socket_,
@@ -113,10 +119,8 @@ void local_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
sizeof(its_end_tag)
),
std::bind(
- &local_client_endpoint_impl::send_tag_cbk,
- std::dynamic_pointer_cast<
- local_client_endpoint_impl
- >(shared_from_this()),
+ &client_endpoint_impl::send_cbk,
+ shared_from_this(),
std::placeholders::_1,
std::placeholders::_2
)
@@ -126,13 +130,28 @@ void local_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
void local_client_endpoint_impl::send_magic_cookie() {
}
-void local_client_endpoint_impl::send_tag_cbk(
+void local_client_endpoint_impl::send_start_tag_cbk(
boost::system::error_code const &_error, std::size_t _bytes) {
+ (void)_bytes;
+ if (_error)
+ send_cbk(_error, 0);
+
+ send_queued_data();
+}
+
+void local_client_endpoint_impl::send_queued_data_cbk(
+ boost::system::error_code const &_error, std::size_t _bytes) {
+ (void)_bytes;
+ if (_error)
+ send_cbk(_error, 0);
+
+ send_end_tag();
}
void local_client_endpoint_impl::receive_cbk(
- packet_buffer_ptr_t _buffer,
boost::system::error_code const &_error, std::size_t _bytes) {
+ (void)_error;
+ (void)_bytes;
VSOMEIP_ERROR << "Local endpoint received message ("
<< _error.message() << ")";
}