Skip to content

Commit

Permalink
still trying to render a damn cube
Browse files Browse the repository at this point in the history
  • Loading branch information
YunxianHua committed Oct 9, 2024
1 parent 85a1b2e commit f1aff24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cobridge_base/include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ using ServiceId = uint32_t;

// coBridge Websocket SubProtocol
// ./cobridge subprotocol/coBridge Websocket SubProtocol.md
constexpr char SUPPORTED_SUB_PROTOCOL[] = "foxglove.websocket.v1";
constexpr char SUPPORTED_SUB_PROTOCOL[] = "coBridge.websocket.v1";
// and of course, we also support foxglove subprotocol
constexpr char FOXGLOVE_SUB_PROTOCOL[] = "foxglove.websocket.v1";
constexpr char CAPABILITY_CLIENT_PUBLISH[] = "clientPublish";
constexpr char CAPABILITY_TIME[] = "time";
constexpr char CAPABILITY_PARAMETERS[] = "parameters";
Expand Down
13 changes: 9 additions & 4 deletions cobridge_base/include/websocket_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,17 +942,22 @@ inline bool Server<ServerConfiguration>::validate_connection(ConnHandle hdl)
auto con = _server.get_con_from_hdl(hdl);

const auto & sub_protocols = con->get_requested_subprotocols();
if (std::find(sub_protocols.begin(), sub_protocols.end(), SUPPORTED_SUB_PROTOCOL) !=
sub_protocols.end())
{

auto it = std::find(sub_protocols.begin(), sub_protocols.end(), SUPPORTED_SUB_PROTOCOL);
if (it != sub_protocols.end()) {
con->select_subprotocol(SUPPORTED_SUB_PROTOCOL);
return true;
}

it = std::find(sub_protocols.begin(), sub_protocols.end(), FOXGLOVE_SUB_PROTOCOL);
if (it != sub_protocols.end()) {
con->select_subprotocol(FOXGLOVE_SUB_PROTOCOL);
return true;
}
_server.get_alog().write(
APP, "Rejecting client " + remote_endpoint_string(hdl) +
" which did not declare support for subprotocol " +
SUPPORTED_SUB_PROTOCOL);
return false;
}

template<typename ServerConfiguration>
Expand Down

0 comments on commit f1aff24

Please sign in to comment.