3 This file is part of libmspnet
4 Copyright © 2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
8 #ifndef MSP_NET_COMMUNICATOR_H_
9 #define MSP_NET_COMMUNICATOR_H_
12 #include "streamsocket.h"
20 sigc::signal<void> signal_handshake_done;
24 const Protocol &protocol;
25 ReceiverBase &receiver;
34 Communicator(StreamSocket &, const Protocol &, ReceiverBase &);
37 void initiate_handshake();
38 bool is_handshake_done() const { return handshake_status==2; }
41 void send(const P &pkt)
43 if(handshake_status!=2)
44 throw InvalidState("Handshaking is not done");
45 unsigned size=protocol.assemble(pkt, out_buf, buf_size);
46 socket.write(out_buf, size);
50 void data_available();
51 bool receive_packet(const Protocol &, ReceiverBase &);
52 void send_handshake();