Skip to content

Commit

Permalink
Add send methods to poco wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Feb 15, 2022
1 parent f93c92f commit 996d6fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['9', '10', '11']
version: ['10', '11']

env:
CC: gcc-${{ matrix.version }}
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['10', '11', '12']
version: ['10', '11', '12', '13']

env:
CC: clang-${{ matrix.version }}
Expand Down
1 change: 1 addition & 0 deletions cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enable_testing()
include_directories(include)
add_executable(simple_websocket_test test/SimpleWebSocketTests.cpp)
target_link_libraries(simple_websocket_test Catch2::Catch2 Poco::Net)
target_compile_options(simple_websocket_test PRIVATE -Wall -Werror -Wno-deprecated-enum-enum-conversion)
include(CTest)
include(Catch)
catch_discover_tests(simple_websocket_test)
11 changes: 9 additions & 2 deletions simple_websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,19 @@ namespace SimpleWebSocket::Poco {
webSocket_.close();
}

[[nodiscard]]
std::span<char> receive(int &flags) {
[[nodiscard]] std::span<char> receive(int &flags) {
char buffer[SIZE];
int bytesReceived = webSocket_.receiveFrame(buffer, SIZE, flags);
return {buffer, static_cast<size_t>(bytesReceived)};
}

int send(const std::string &message, int opCode) {
return webSocket_.sendFrame(message.c_str(), static_cast<int>(message.length()), opCode);
}

int send(std::span<char> buffer, int opCode) {
return webSocket_.sendBytes(buffer.data(), static_cast<int>(buffer.size()), opCode);
}

private:
::Poco::Net::WebSocket webSocket_;
Expand Down

0 comments on commit 996d6fe

Please sign in to comment.