| | |
| | | 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"]) {
|
| | |
| | | msg["wav_format"], (ASR_TYPE)asr_mode_);
|
| | | } else {
|
| | | msg["access_num"]=(int)msg["access_num"]-1;
|
| | | |
| | | return;
|
| | | }
|
| | | } catch (std::exception const& e) {
|
| | |
| | |
|
| | | } catch (std::exception const& e) {
|
| | | std::cerr << "Error: " << e.what() << std::endl;
|
| | |
|
| | | }
|
| | | msg["access_num"]=(int)msg["access_num"]-1;
|
| | |
|
| | |
| | | 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
|
| | |
| | | data_map.erase(hdl);
|
| | | }
|
| | |
|
| | | |
| | | guard_decoder.unlock();
|
| | | // remove data vector when connection is closed
|
| | | }
|
| | |
| | | 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
|
| | |
| | | }
|
| | | }
|
| | | catch (std::exception const &e)
|
| | | |
| | | {
|
| | | // if connection is close, we set is_eof = true
|
| | | std::shared_ptr<FUNASR_MESSAGE> data_msg = nullptr;
|
| | |
| | | remove_hdl(hdl, data_map);
|
| | | LOG(INFO) << "remove one connection ";
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | void WebSocketServer::on_message(websocketpp::connection_hdl hdl,
|