[Libwebsockets] multiple connections to shared worker process

Per Bothner per at bothner.com
Fri Jul 7 07:35:47 CEST 2017


I recently implemented support for multiple panes and tabs in DomTerm:
http://per.bothner.com/blog/2017/domterm-draggable-panes/
It's pretty neat - please check it out.

To "complete" the functionality of screen/tmux I need add session management.
That means decoupling the websocket connection (to the browser) from the pty worker process.
Currently, the worker process has its own wsi (used for polling
of pty output) and that wsi's parent is the websocket wsi.
However, I believe we need to invert this: A pty process
may be attached to multiple websocket connections (if, for example,
multiple users are connected to the same screen).  In that case
output from the pty needs to be sent to each websocket client.
A pty process may also be connected to zero websocket connections,
corresponding to a detached session.

I've started splitting up the data structures to support this.  So far so good,
but I expect I'll have some questions once I actually attempt multiple connections per pty.
Any advice? Is there example code for how to do this?  For example a classic
chat/mud server based on lws would be helpful.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/


More information about the Libwebsockets mailing list