-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
hello
how to define few ws routes?
for example,
from page 1 we connect to ws://localhost:8080/echo
and from page 2 we connect to ws://localhost:8081/ws2
but in dlang serverino code -
// Accept a new connection only if the request path is "/echo"
@onWebSocketUpgrade bool onUpgrade(Request req){
return req.path == "/echo";
}
// Handle the WebSocket connection
@endpoint void echo(Request r, WebSocket ws){
// Read messages from the client
while(true){
// Only if the message is valid
if( WebSocketMessage msg = ws.receiveMessage() ){
// Send the message back to the client
ws.send("I received your message: `" ~ msg.asString ~ "`");
}
}
}
@route!"/"
@endpoint void index(Request r, Output o){ o.serveFile("static/index.html"); }
@route!"/style.css"
@endpoint void css(Request r, Output o){ o.serveFile("static/style.css"); }
what - and how - needs to change here?
for get different paths - and handlers - for different ws paths - as for different http path
thank you
Metadata
Metadata
Assignees
Labels
No labels