50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
//#include <websocketpp/config/asio_no_tls.hpp>
|
|
//#include <websocketpp/server.hpp>
|
|
#include "typeDef.h"
|
|
#include <map>
|
|
#include <queue>
|
|
#include <mutex>
|
|
//typedef websocketpp::server<websocketpp::config::asio> websocketsvr;
|
|
//typedef websocketsvr::message_ptr message_ptr;
|
|
|
|
using websocketpp::lib::placeholders::_1;
|
|
using websocketpp::lib::placeholders::_2;
|
|
using websocketpp::lib::bind;
|
|
|
|
enum ERR_MSG;
|
|
|
|
class VideoSocketService
|
|
{
|
|
public:
|
|
static VideoSocketService* getInstance();
|
|
|
|
void Start(uint16_t port);
|
|
|
|
void Stop();
|
|
|
|
void PushImg(std::string img);
|
|
private:
|
|
|
|
VideoSocketService();
|
|
~VideoSocketService();
|
|
VideoSocketService(VideoSocketService&) = delete;
|
|
VideoSocketService& operator=(const VideoSocketService&) = delete;
|
|
|
|
void OnWebSocketOpen(websocketsvr *server, websocketpp::connection_hdl hdl);
|
|
void OnWebSocketClose(websocketsvr *server, websocketpp::connection_hdl hdl);
|
|
void OnWebSocketMessage(websocketsvr *server, websocketpp::connection_hdl hdl, message_ptr msg);
|
|
|
|
void PushImageThread();
|
|
|
|
private:
|
|
websocketsvr m_web_server;
|
|
std::mutex m_mt;
|
|
websocketpp::connection_hdl m_hdl;
|
|
std::queue<std::string> m_img_list;
|
|
|
|
std::map<std::string, MSG_ACTION> ACTIONS;
|
|
std::map< ERR_MSG, std::string> MSG;
|
|
};
|
|
|