// Copyright (C) 2014-2016 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef VSOMEIP_SERVER_IMPL_HPP #define VSOMEIP_SERVER_IMPL_HPP #include #include #include #include #include #include #include #include #include "buffer.hpp" #include "endpoint_impl.hpp" namespace vsomeip { template class server_endpoint_impl: public endpoint_impl, public std::enable_shared_from_this > { public: typedef typename Protocol::socket socket_type; typedef typename Protocol::endpoint endpoint_type; typedef typename std::map > queue_type; typedef typename queue_type::iterator queue_iterator_type; server_endpoint_impl(std::shared_ptr _host, endpoint_type _local, boost::asio::io_service &_io, std::uint32_t _max_message_size); virtual ~server_endpoint_impl(); bool is_client() const; bool is_connected() const; bool send(const uint8_t *_data, uint32_t _size, bool _flush); virtual void stop(); bool flush(endpoint_type _target); public: void connect_cbk(boost::system::error_code const &_error); void send_cbk(queue_iterator_type _queue_iterator, boost::system::error_code const &_error, std::size_t _bytes); void flush_cbk(endpoint_type _target, const boost::system::error_code &_error); public: virtual bool send_intern(endpoint_type _target, const byte_t *_data, uint32_t _port, bool _flush); virtual void send_queued(queue_iterator_type _queue_iterator) = 0; virtual endpoint_type get_remote() const = 0; virtual bool get_default_target(service_t _service, endpoint_type &_target) const = 0; protected: std::map packetizer_; queue_type queues_; std::mutex clients_mutex_; std::map > clients_; boost::asio::steady_timer flush_timer_; std::mutex mutex_; }; } // namespace vsomeip #endif // VSOMEIP_SERVICE_ENDPOINT_IMPL_HPP