雾聪
2023-08-11 44e7762ce6d7890592599cb1a1393448f9a7a218
funasr/runtime/websocket/websocket-server-2pass.cpp
@@ -104,7 +104,6 @@
    asr_mode_ = 2;
  }
    // loop to send chunk_size 800*2 data to asr engine.   TODO: chunk_size need
    // get from client
    while (buffer.size() >= 800 * 2 && !msg["is_eof"]) {
@@ -153,7 +152,6 @@
                                       msg["wav_format"], (ASR_TYPE)asr_mode_);
        } else {
        msg["access_num"]=(int)msg["access_num"]-1;
          return;
        }
      } catch (std::exception const& e) {
@@ -184,7 +182,6 @@
  } catch (std::exception const& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
  msg["access_num"]=(int)msg["access_num"]-1;
 
@@ -193,9 +190,6 @@
void WebSocketServer::on_open(websocketpp::connection_hdl hdl) {
  scoped_lock guard(m_lock);     // for threads safty
  try{
  std::shared_ptr<FUNASR_MESSAGE> data_msg =
      std::make_shared<FUNASR_MESSAGE>();  // put a new data vector for new
                                           // connection
@@ -242,7 +236,6 @@
   data_map.erase(hdl);
  }
  
  guard_decoder.unlock();
    // remove data vector when  connection is closed
}
@@ -266,7 +259,6 @@
void WebSocketServer::check_and_clean_connection() {
   LOG(INFO)<<"***********begin check_and_clean_connection ****************";
 while(true){
  std::this_thread::sleep_for(std::chrono::milliseconds(5000));
  LOG(INFO) << "run check_and_clean_connection" <<", active connections: " << data_map.size();;
  std::vector<websocketpp::connection_hdl> to_remove;  // remove list
@@ -287,7 +279,6 @@
    }
    }
    catch (std::exception const &e)
    {
       // if connection is close, we set is_eof = true
        std::shared_ptr<FUNASR_MESSAGE> data_msg = nullptr;
@@ -311,7 +302,6 @@
    remove_hdl(hdl, data_map);
    LOG(INFO) << "remove one connection ";
  }
 }
}
void WebSocketServer::on_message(websocketpp::connection_hdl hdl,