My vibe.d-based web server application serves currently as an augmented proxy (or a mediator) between a set of application logic servers (listening on TCP sockets) and users' browsers (receiving data via websockets).

In particular, the use case goes as follows:

  • after a user logs in in a browser,
  • a TCP connection is established from vibe.d server to one of the end servers,
  • that server verifies the credentials and
  • the user is supplied an HTML page with session-based web socket establishment code,
  • in turn, the browser creates that websocket connection to my vibe.d server,
  • the websocket handling function notifies the other task, so that it can start resending data from the TCP connection,
  • this websocket handling function then resends data to the browser,
  • finally, the user sees online updated data (sent from the end server) in the browser.

As I need to manage the connection status of both tied connections (ws, tcp) in various places while processing data from either end, it would be beneficial to have these (both) connections served within a single thread by different fibers, so they can shared TLS data. As I do not see a way how to make vibe.d open a websocket connection in a specific thread (the one of the already established TCP connection to an end server), I would go with a passing of the websocket over to the end server connection handling task and setting up the handling of the websocket with runTask() from there to stay in the same thread.

What is a proper way how to pass a websocket connection to another task in a different thread?

Thank you very much in advance for hints of any kind.
Ľudovít