zhaomingwork
2023-05-12 5ed359464f1683ca505d59bb4b8a7ed4ae98e10b
funasr/runtime/websocket/websocketsrv.h
@@ -30,7 +30,7 @@
#include "asio.hpp"
#include "com-define.h"
#include "libfunasrapi.h"
#include "funasrruntime.h"
#include "nlohmann/json.hpp"
#include "tclap/CmdLine.h"
typedef websocketpp::server<websocketpp::config::asio> server;
@@ -45,6 +45,11 @@
  std::string msg;
  float snippet_time;
} FUNASR_RECOG_RESULT;
typedef struct {
  nlohmann::json msg;
  std::shared_ptr<std::vector<char>> samples;
} FUNASR_MESSAGE;
class WebSocketServer {
 public:
@@ -87,6 +92,10 @@
  std::map<websocketpp::connection_hdl, std::shared_ptr<std::vector<char>>,
           std::owner_less<websocketpp::connection_hdl>>
      sample_map;
  std::map<websocketpp::connection_hdl, std::shared_ptr<FUNASR_MESSAGE>,
           std::owner_less<websocketpp::connection_hdl>>
      data_map;
  websocketpp::lib::mutex m_lock;  // mutex for sample_map
};