1 #ifndef MSP_NET_COMMUNICATOR_H_
2 #define MSP_NET_COMMUNICATOR_H_
4 #include <sigc++/signal.h>
12 class sequence_error: public std::logic_error
15 sequence_error(const std::string &w): std::logic_error(w) { }
18 class incompatible_protocol: public std::runtime_error
21 incompatible_protocol(const std::string &w): std::runtime_error(w) { }
28 sigc::signal<void> signal_handshake_done;
29 sigc::signal<void, const std::exception &> signal_error;
33 const Protocol &protocol;
34 ReceiverBase &receiver;
44 Communicator(StreamSocket &, const Protocol &, ReceiverBase &);
47 void initiate_handshake();
48 bool is_handshake_done() const { return handshake_status==2; }
54 void send_data(std::size_t);
56 void data_available();
57 bool receive_packet(const Protocol &, ReceiverBase &);
58 void send_handshake();
62 void Communicator::send(const P &pkt)
64 send_data(protocol.serialize(pkt, out_buf, buf_size));