webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.96k stars 172 forks source link

Does every new window listen on a new port? #290

Closed jinzhongjia closed 9 months ago

jinzhongjia commented 9 months ago

Does every new window listen on a new port? And the new window uses the new port to establish a new websocket connection? If so, is the cost a bit too much?

fibodevy commented 9 months ago

The port is random, only one client (window) can be connected at the same time to a single WebUI app instance

jinzhongjia commented 9 months ago

The port is random, only one client (window) can be connected at the same time to a single WebUI app instance

yes, when we open two windows( two clients), that means webui listens two ports, right?

fibodevy commented 9 months ago

You mean 2 applications which is 2 servers and 2 browser windows? Then yes

jinzhongjia commented 9 months ago

You mean 2 applications which is 2 servers and 2 browser windows? Then yes

Yes, that's what I mean. This cost is a little high?

fibodevy commented 9 months ago

This is the only way it can be done. Only one app can listen on one specific port.

Cost is not high at all. Many applications communicate using TCP/IP as interprocess communication in the background.

jinzhongjia commented 9 months ago

whether it is possible to have only one server, corresponding to multiple clients

fibodevy commented 9 months ago

Since removal of webui_set_multi_access() only one client can be connected to a single WebUI instance. Connection is also protected with a token to ensure only 1 connected client.

Inside your app, you can have multiple WebUI instances (webui_new_window -> webui_show), all of them can handle 1 client. Every new WebUI window instance will listen on a new port.

jinzhongjia commented 9 months ago

ok, I get it.

hassandraga commented 9 months ago

Good question @jinzhongjia. The issue is if a window continually exchange large data it may effect other windows communication when using one single server.

Another issue when using one single server is many window specific options/features will become global options for all windows instead of window specific. For example allow a window to be accessible from the public network, or setting the root folder.

As @fibodevy said, this is the only way to do it, unless someone find another design.

jinzhongjia commented 9 months ago

Good question @jinzhongjia. The issue is if a window continually exchange large data it may effect other windows communication when using one single server.

Another issue when using one single server is many window specific options/features will become global options for all windows instead of window specific. For example allow a window to be accessible from the public network, or setting the root folder.

As @fibodevy said, this is the only way to do it, unless someone find another design.

I get it, thanks for your answer.