Open ademDurakovic opened 3 months ago
(2024-03-31 22:24:17) [INFO ] Crow/master server is running at http://0.0.0.0:18080 using 2 threads
(2024-03-31 22:24:17) [INFO ] Call app.loglevel(crow::LogLevel::Warning)
to hide Info level logs.
(2024-03-31 22:24:23) [INFO ] Closing IO service 0x600003828280
(2024-03-31 22:24:23) [INFO ] Closing main IO service (0x134e04958)
(2024-03-31 22:24:23) [INFO ] Exiting.
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)?
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.