#ifndef STREAM_SERVER_H #define STREAM_SERVER_H #include #include #include #include #include #include #include "serverConnection.h" #include "common/timeUtils.h" #include "common/queue.h" #include "common/message.h" #include "common/headerMessage.h" #include "common/sampleFormat.h" using boost::asio::ip::tcp; typedef std::shared_ptr socket_ptr; using namespace std; class StreamSession : public ServerConnection { public: StreamSession(socket_ptr sock); void send(shared_ptr message); protected: virtual void worker(); thread* senderThread; Queue> messages; }; class StreamServer { public: StreamServer(unsigned short port); void send(shared_ptr message); void start(); void stop(); private: void acceptor(); set> sessions; boost::asio::io_service io_service_; unsigned short port_; shared_ptr headerChunk; shared_ptr sampleFormat; thread* acceptThread; }; class ServerException : public std::exception { public: ServerException(const std::string& what) : what_(what) { } virtual ~ServerException() throw() { } virtual const char* what() const throw() { return what_.c_str(); } private: std::string what_; }; #endif