mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support
BSD 2-Clause "Simplified" License
724 stars 120 forks source link

Server::addWebSocketHandler doesn't warn when there is no "/" in the endpoint #203

Open Zydnar opened 2 weeks ago

Zydnar commented 2 weeks ago

I tried to define a WebSocket endpoint like this:

server.addWebSocketHandler("pin_handler", std::make_shared<ChatHandler>());

And no matter what I tried, the client in whatever language either freezed at readyState 0 (connection CLOSED) or it couldn't connect - from server side I get Couldn't find WebSocket endpoint for '/pin_handler' However everything's fine when I add /

server.addWebSocketHandler("/pin_handler", std::make_shared<ChatHandler>());

So my suggestion is to check in Server::addWebSocketHandler if edpoint string starts with / and either add it or at least warn about it.