-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket Question #787
Comments
(2024-03-31 22:24:17) [INFO ] Crow/master server is running at http://0.0.0.0:18080 using 2 threads Process finished with exit code 0 this is the output if it helps. |
How do you call server (address, port, request etc)? Are there any prints on console (about started/closed connection)? |
What do you mean by call server? (sorry don't really understand all this) and no prints were made to the console I thought when I ran this code that the print in the .onopen() would be called but it doesn't. |
I mean how your request looks like? WS URL, what data do you try to push? Do you see that connection was established on client side? Is response visible on client? |
Hi, I am writing a project that needs to have a c++ back end and I have a react front end.
I want to use web sockets with Crow to do this. I am trying to set it up but I don't really know if it's working nor do I have much experience with this. Currently this is my code and I just want to do a print to the terminal when the socket opens but the print never comes although the code seems to run fine.
Does this look correct or am I doing something wrong?
Here is my code:
#include "crow.h"
#include "crow/websocket.h"
int main() {
crow::SimpleApp app;
CROW_WEBSOCKET_ROUTE(app, "/ws")
.onopen([](crow::websocket::connection& conn) {
// Handle WebSocket connection open event
// For example, you can send a welcome message to the client
conn.send_text("WebSocket connection opened");
}
Also, should I be doing web sockets or just normal HTTP? What do you guys think is simpler? I was doing HTTP but then I was just getting a bunch of annoying CORS errors in my front end so I thought I'd try web socket. The project is just a simple casino game room.
I appreciate the help.
The text was updated successfully, but these errors were encountered: