1 #ifndef MSP_NET_COMMUNICATOR_H_
2 #define MSP_NET_COMMUNICATOR_H_
5 #include "streamsocket.h"
10 class sequence_error: public std::logic_error
13 sequence_error(const std::string &w): std::logic_error(w) { }
14 virtual ~sequence_error() throw() { }
21 sigc::signal<void> signal_handshake_done;
25 const Protocol &protocol;
26 ReceiverBase &receiver;
36 Communicator(StreamSocket &, const Protocol &, ReceiverBase &);
39 void initiate_handshake();
40 bool is_handshake_done() const { return handshake_status==2; }
43 void send(const P &pkt)
46 throw sequence_error("connection aborted");
47 if(handshake_status!=2)
48 throw sequence_error("handshaking not done");
49 unsigned size = protocol.assemble(pkt, out_buf, buf_size);
50 socket.write(out_buf, size);
54 void data_available();
55 bool receive_packet(const Protocol &, ReceiverBase &);
56 void send_handshake();