- Use the `bindPort` parameter when configuring the HTTP server
- Updated type of `bindPort` to `ushort`
- Save the newly created `Connection` instance into its own variable
- Do the fiber call later

App

- Updated type of `bindPort` to `ushort`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-02-27 13:23:29 +02:00
parent 920eea8e56
commit eed104df64
2 changed files with 11 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import nostril.server;
void main() void main()
{ {
string[] bindAddresseds = ["::"]; string[] bindAddresseds = ["::"];
int bindPort = 8082; ushort bindPort = 8082;
Server server = new Server(bindAddresseds, bindPort); Server server = new Server(bindAddresseds, bindPort);
server.startServer(); server.startServer();
} }

View File

@ -35,11 +35,11 @@ public class Server
this(string[] bindAddresses, int bindPort) this(string[] bindAddresses, ushort bindPort)
{ {
// Setup where to listen // Setup where to listen
this.httpSettings = new HTTPServerSettings(); this.httpSettings = new HTTPServerSettings();
httpSettings.port = 8082; httpSettings.port = bindPort;
httpSettings.bindAddresses = bindAddresses; httpSettings.bindAddresses = bindAddresses;
// Setup a websocket negotiater with a handler attached // Setup a websocket negotiater with a handler attached
@ -78,7 +78,14 @@ public class Server
*/ */
void websocketHandler(scope WebSocket socket) void websocketHandler(scope WebSocket socket)
{ {
new Connection(socket).call(); /* Create a new connection to handle this client */
Connection connection = new Connection(socket);
/* Add it to the queue */
// TODO: Add this
/* Call the fiber and let it start */
connection.call();
} }