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) { }
16 virtual ~sequence_error() throw() { }
19 class incompatible_protocol: public std::runtime_error
22 incompatible_protocol(const std::string &w): std::runtime_error(w) { }
23 virtual ~incompatible_protocol() throw() { }
30 sigc::signal<void> signal_handshake_done;
31 sigc::signal<void, const std::exception &> signal_error;
35 const Protocol &protocol;
36 ReceiverBase &receiver;
46 Communicator(StreamSocket &, const Protocol &, ReceiverBase &);
49 void initiate_handshake();
50 bool is_handshake_done() const { return handshake_status==2; }
56 void send_data(unsigned);
58 void data_available();
59 bool receive_packet(const Protocol &, ReceiverBase &);
60 void send_handshake();
64 void Communicator::send(const P &pkt)
66 send_data(protocol.serialize(pkt, out_buf, buf_size));