3 This file is part of the MSP Märklin suite
4 Copyright © 2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef MARKLINNET_SERVER_H_
9 #define MARKLINNET_SERVER_H_
11 #include <msp/io/eventdispatcher.h>
12 #include <msp/net/communicator.h>
13 #include <msp/net/streamsocket.h>
14 #include <msp/net/streamlistensocket.h>
15 #include "libmarklin/trafficmanager.h"
24 struct Connection: private Msp::Net::PacketReceiver<TrainSpeedPacket>,
25 private Msp::Net::PacketReceiver<TrainFunctionPacket>
28 Msp::Net::StreamSocket *socket;
29 Msp::Net::Communicator comm;
32 Connection(Server &, Msp::Net::StreamSocket *);
35 void handshake_done();
37 virtual void receive(const TrainSpeedPacket &);
38 virtual void receive(const TrainFunctionPacket &);
42 TrafficManager &trfc_mgr;
43 Msp::Net::StreamListenSocket listen_sock;
44 Msp::IO::EventDispatcher *event_disp;
45 std::vector<Connection *> connections;
48 Server(TrafficManager &);
49 void use_event_dispatcher(Msp::IO::EventDispatcher &);
51 void incoming_connection();
53 void train_added(Train &);
54 void train_speed_changed(const Train &, unsigned);
55 void train_function_changed(const Train &, unsigned, bool);
56 void train_status_changed(const Train &, const std::string &);
62 } // namespace Marklin