BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
message_oriented_connection.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
26 #include <graphene/net/message.hpp>
27 
28 namespace graphene { namespace net {
29 
30  namespace detail { class message_oriented_connection_impl; }
31 
33 
36  {
37  public:
38  virtual void on_message(message_oriented_connection* originating_connection, const message& received_message) = 0;
39  virtual void on_connection_closed(message_oriented_connection* originating_connection) = 0;
40  };
41 
44  {
45  public:
49 
50  void accept();
51  void bind(const fc::ip::endpoint& local_endpoint);
52  void connect_to(const fc::ip::endpoint& remote_endpoint);
53 
54  void send_message(const message& message_to_send);
55  void close_connection();
56  void destroy_connection();
57 
58  uint64_t get_total_bytes_sent() const;
59  uint64_t get_total_bytes_received() const;
64  private:
65  std::unique_ptr<detail::message_oriented_connection_impl> my;
66  };
67  typedef std::shared_ptr<message_oriented_connection> message_oriented_connection_ptr;
68 
69 } } // graphene::net
message.hpp
graphene::net::message_oriented_connection::get_total_bytes_sent
uint64_t get_total_bytes_sent() const
Definition: message_oriented_connection.cpp:425
graphene::net::message_oriented_connection_delegate
Definition: message_oriented_connection.hpp:35
graphene::net::message_oriented_connection::connect_to
void connect_to(const fc::ip::endpoint &remote_endpoint)
Definition: message_oriented_connection.cpp:400
graphene::net::message
Definition: message.hpp:58
graphene::net::message_oriented_connection
Definition: message_oriented_connection.hpp:43
graphene::net::message_oriented_connection::~message_oriented_connection
~message_oriented_connection()
Definition: message_oriented_connection.cpp:386
graphene::net::message_oriented_connection::get_socket
fc::tcp_socket & get_socket()
Definition: message_oriented_connection.cpp:390
graphene::net::detail::message_oriented_connection_impl
Definition: message_oriented_connection.cpp:51
fc::ip::endpoint
Definition: ip.hpp:65
fc::sha512
Definition: sha512.hpp:9
graphene::net::message_oriented_connection::get_last_message_sent_time
fc::time_point get_last_message_sent_time() const
Definition: message_oriented_connection.cpp:435
graphene::net::message_oriented_connection::get_last_message_received_time
fc::time_point get_last_message_received_time() const
Definition: message_oriented_connection.cpp:440
graphene::net::message_oriented_connection::bind
void bind(const fc::ip::endpoint &local_endpoint)
Definition: message_oriented_connection.cpp:405
fc::tcp_socket
Definition: tcp_socket.hpp:14
fc::time_point
Definition: time.hpp:44
graphene::net::message_oriented_connection::get_shared_secret
fc::sha512 get_shared_secret() const
Definition: message_oriented_connection.cpp:448
graphene::net::message_oriented_connection_delegate::on_connection_closed
virtual void on_connection_closed(message_oriented_connection *originating_connection)=0
graphene::net::message_oriented_connection::destroy_connection
void destroy_connection()
Definition: message_oriented_connection.cpp:420
graphene::net::message_oriented_connection::send_message
void send_message(const message &message_to_send)
Definition: message_oriented_connection.cpp:410
graphene::net::message_oriented_connection::accept
void accept()
Definition: message_oriented_connection.cpp:395
tcp_socket.hpp
graphene::net::message_oriented_connection::message_oriented_connection
message_oriented_connection(message_oriented_connection_delegate *delegate=nullptr)
Definition: message_oriented_connection.cpp:381
graphene::net::message_oriented_connection::close_connection
void close_connection()
Definition: message_oriented_connection.cpp:415
graphene::net::message_oriented_connection::get_total_bytes_received
uint64_t get_total_bytes_received() const
Definition: message_oriented_connection.cpp:430
graphene::net::message_oriented_connection_delegate::on_message
virtual void on_message(message_oriented_connection *originating_connection, const message &received_message)=0
graphene
Definition: api.cpp:48
graphene::net::message_oriented_connection_ptr
std::shared_ptr< message_oriented_connection > message_oriented_connection_ptr
Definition: message_oriented_connection.hpp:67
graphene::net::message_oriented_connection::get_connection_time
fc::time_point get_connection_time() const
Definition: message_oriented_connection.cpp:444