Browsers in D

Adam D Ruppe destructionator at gmail.com
Thu Dec 21 22:29:03 UTC 2023


On Thursday, 21 December 2023 at 11:55:50 UTC, aberba wrote:
> I have this idea of building a web view based desktop app with 
> a webserver and db backend for CRUD functionality. This looks 
> like a great option.

Yeah, it is a solid choice with a long history. Did you know the 
Unix Printing System used to (I don't think it still does but im 
not sure) work this way? Some 15 years ago, it'd start up a local 
web server and you'd work with it through the browser.

I do kinda wish that the common browsers supported connecting 
through a local unix socket, so you wouldn't have to allocate a 
port... but you don't really have to allocate a port anyway - you 
can let the OS give you a random available one then you see what 
it assigned you and pop open the browser. So it still works.

Another interesting thing available nowadays is some programs 
will run a webview ui but also open a websocket server, allowing 
other websites to interact with it. With a websocket server, any 
random internet page is allowed to try to connect to it - yes, 
normal javascript is allowed to try to connect a websocket to 
localhost - and your server checks the `origin` header to see if 
it is a website you want to talk to.

The Discord desktop client uses this, for example, to let their 
official sites detect the local client and ask if you want to 
"open link in app" (which i kinda hate lol but it does) and also 
to communicate some special features to it, like a discord 
website can show who is currently speaking in the voice to 
display on your web streams. (I know this cuz i hooked into it to 
make my own thing lol).

But it is still a potential way to combine all these options for 
your users.


More information about the Digitalmars-d-announce mailing list