1 #ifndef R2C2_NET_SERVER_H_
2 #define R2C2_NET_SERVER_H_
4 #include <msp/io/eventdispatcher.h>
5 #include <msp/net/communicator.h>
6 #include <msp/net/streamsocket.h>
7 #include <msp/net/streamlistensocket.h>
8 #include "libr2c2/layout.h"
9 #include "libr2c2/trainstatus.h"
18 struct Connection: Msp::Net::PacketReceiver<DriverStatePacket>,
19 Msp::Net::PacketReceiver<TrainControlPacket>,
20 Msp::Net::PacketReceiver<TrainFunctionPacket>,
21 Msp::Net::PacketReceiver<TrainRoutePacket>
24 Msp::Net::StreamSocket *socket;
25 Msp::Net::Communicator comm;
28 Connection(Server &, Msp::Net::StreamSocket *);
31 void handshake_done();
33 virtual void receive(const DriverStatePacket &);
34 virtual void receive(const TrainControlPacket &);
35 virtual void receive(const TrainFunctionPacket &);
36 virtual void receive(const TrainRoutePacket &);
37 void error(const std::string &);
42 Msp::Net::StreamListenSocket listen_sock;
43 Msp::IO::EventDispatcher *event_disp;
44 std::vector<Connection *> connections;
48 void use_event_dispatcher(Msp::IO::EventDispatcher &);
50 void incoming_connection();
52 void driver_state_changed();
53 void emergency(const std::string &);
54 void train_added(Train &);
55 void train_control_changed(const Train &, const std::string &, float);
56 void train_function_changed(const Train &, unsigned, bool);
57 void train_route_changed(const Train &, const Route *);
58 void train_status_changed(const Train &, const std::string &);