-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add streaming websocket server and client (#62)
- Loading branch information
1 parent
ce4dd17
commit 40522f0
Showing
20 changed files
with
1,197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function(download_asio) | ||
include(FetchContent) | ||
|
||
set(asio_URL "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-24-0.tar.gz") | ||
set(asio_HASH "SHA256=cbcaaba0f66722787b1a7c33afe1befb3a012b5af3ad7da7ff0f6b8c9b7a8a5b") | ||
|
||
# If you don't have access to the Internet, | ||
# please pre-download asio | ||
set(possible_file_locations | ||
$ENV{HOME}/Downloads/asio-asio-1-24-0.tar.gz | ||
${PROJECT_SOURCE_DIR}/asio-asio-1-24-0.tar.gz | ||
${PROJECT_BINARY_DIR}/asio-asio-1-24-0.tar.gz | ||
/tmp/asio-asio-1-24-0.tar.gz | ||
/star-fj/fangjun/download/github/asio-asio-1-24-0.tar.gz | ||
) | ||
|
||
foreach(f IN LISTS possible_file_locations) | ||
if(EXISTS ${f}) | ||
set(asio_URL "file://${f}") | ||
break() | ||
endif() | ||
endforeach() | ||
|
||
FetchContent_Declare(asio | ||
URL ${asio_URL} | ||
URL_HASH ${asio_HASH} | ||
) | ||
|
||
FetchContent_GetProperties(asio) | ||
if(NOT asio_POPULATED) | ||
message(STATUS "Downloading asio ${asio_URL}") | ||
FetchContent_Populate(asio) | ||
endif() | ||
message(STATUS "asio is downloaded to ${asio_SOURCE_DIR}") | ||
# add_subdirectory(${asio_SOURCE_DIR} ${asio_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
include_directories(${asio_SOURCE_DIR}/asio/include) | ||
endfunction() | ||
|
||
download_asio() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function(download_websocketpp) | ||
include(FetchContent) | ||
|
||
# The latest commit on the develop branch os as 2022-10-22 | ||
set(websocketpp_URL "https://github.com/zaphoyd/websocketpp/archive/b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip") | ||
set(websocketpp_HASH "SHA256=1385135ede8191a7fbef9ec8099e3c5a673d48df0c143958216cd1690567f583") | ||
|
||
# If you don't have access to the Internet, | ||
# please pre-download websocketpp | ||
set(possible_file_locations | ||
$ENV{HOME}/Downloads/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip | ||
${PROJECT_SOURCE_DIR}/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip | ||
${PROJECT_BINARY_DIR}/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip | ||
/tmp/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip | ||
/star-fj/fangjun/download/github/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip | ||
) | ||
|
||
foreach(f IN LISTS possible_file_locations) | ||
if(EXISTS ${f}) | ||
set(websocketpp_URL "file://${f}") | ||
break() | ||
endif() | ||
endforeach() | ||
|
||
FetchContent_Declare(websocketpp | ||
URL ${websocketpp_URL} | ||
URL_HASH ${websocketpp_HASH} | ||
) | ||
|
||
FetchContent_GetProperties(websocketpp) | ||
if(NOT websocketpp_POPULATED) | ||
message(STATUS "Downloading websocketpp from ${websocketpp_URL}") | ||
FetchContent_Populate(websocketpp) | ||
endif() | ||
message(STATUS "websocketpp is downloaded to ${websocketpp_SOURCE_DIR}") | ||
# add_subdirectory(${websocketpp_SOURCE_DIR} ${websocketpp_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
include_directories(${websocketpp_SOURCE_DIR}) | ||
endfunction() | ||
|
||
download_websocketpp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exclude_files=tee-stream.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// sherpa-onnx/csrc/file-utils.cc | ||
// | ||
// Copyright (c) 2022-2023 Xiaomi Corporation | ||
|
||
#include "sherpa-onnx/csrc/file-utils.h" | ||
|
||
#include <fstream> | ||
#include <string> | ||
|
||
#include "sherpa-onnx/csrc/log.h" | ||
|
||
namespace sherpa_onnx { | ||
|
||
bool FileExists(const std::string &filename) { | ||
return std::ifstream(filename).good(); | ||
} | ||
|
||
void AssertFileExists(const std::string &filename) { | ||
if (!FileExists(filename)) { | ||
SHERPA_ONNX_LOG(FATAL) << filename << " does not exist!"; | ||
} | ||
} | ||
|
||
} // namespace sherpa_onnx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// sherpa-onnx/csrc/file-utils.h | ||
// | ||
// Copyright (c) 2022-2023 Xiaomi Corporation | ||
|
||
#ifndef SHERPA_ONNX_CSRC_FILE_UTILS_H_ | ||
#define SHERPA_ONNX_CSRC_FILE_UTILS_H_ | ||
|
||
#include <fstream> | ||
#include <string> | ||
|
||
namespace sherpa_onnx { | ||
|
||
/** Check whether a given path is a file or not | ||
* | ||
* @param filename Path to check. | ||
* @return Return true if the given path is a file; return false otherwise. | ||
*/ | ||
bool FileExists(const std::string &filename); | ||
|
||
/** Abort if the file does not exist. | ||
* | ||
* @param filename The file to check. | ||
*/ | ||
void AssertFileExists(const std::string &filename); | ||
|
||
} // namespace sherpa_onnx | ||
|
||
#endif // SHERPA_ONNX_CSRC_FILE_UTILS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.