Closed andre2007 closed 3 years ago
The main impl just uses an alias
so you might be able to put a lambda in there to forward it to an instance.
Or if you can make that thing static
it will just work.
The problem here is just that socketHandler
needs an object instance to pass as this
and since the cgi main impl doesn't know how to make one, you've gotta pass one in from the outside somehow.
Fantastic, it works great with lambda.
I found one small drawback, while it compiles fine on linux, it fails to compile on Windows:
C:\Users\user\AppData\Local\dub\packages\arsd-official-5.2.4\arsd-official\cgi.d(3490,18): Error: constructor arsd.cgi.ListeningConnectionManager.this(string host, ushort port, void function(Socket) handler) is not callable using argument types (string, ushort, void delegate(Socket connection) @system) C:\Users\user\AppData\Local\dub\packages\arsd-official-5.2.4\arsd-official\cgi.d(3490,18): cannot pass argument &doThreadHttpConnection of type void delegate(Socket connection) @system to parameter void function(Socket) handler source\digitaltwin\concom\server.d(54,13): Error: template instance digitaltwin.concom.server.WebsocketServer.serveForever.cgiMainImpl!((cgi) { socketHandler(cgi); } , Cgi, 5000000L)
This is related to this coding
version(embedded_httpd) {
version(linux)
version=embedded_httpd_processes;
else {
version=embedded_httpd_threads;
}
hmmmmmmmm just changing that opens up threading issues......
Isn't this fixed now? I forgot where the test case is... but I think I did fix it a couple months later...
Yes, thanks a lot.
I am not sure whether I overlook s.th. Is there any possibility to use a delegate / instance method as request handler?
The idea is roughly: