Files
UDN/.README.md.swp
T

15 lines
28 KiB
Plaintext
Raw Normal View History

2026-10-12 20:38:04 +02:00
b0VIM 9.0ß(Íj©“Ngitlocalhost~git/storage/VDMDI/UDN/README.mdutf-8
3210#"! U
"
² O æåáàÈǹ¸-Ô54Èǵ´ƒ‚POAäÅ~]B*($#éÂÁ­ˆ‡QP;: ùÊ©¨�“bO´- Remove non-english translations - the UDN web interface is intended for administrators only, maintenance of multiple translations slows down development- Add imprint link- Add privacy policy for public-facing instances## 1.0.1:# Changes4. Send the string via WebSocket3. Stringify the object via `JSON.stringify()`2. Add the properties you want to send1. Create an empty object**Sending messages**3. Define functions to send whatever you need to send- handle it in whatever way you need- parse the message2. Listen to messages, when receiving:1. Create a WebSocket connection to the server**Setup**```} messageBody?: string; messageChannel?: string; //sending or receiving message subscribed?: boolean; // sent by the server to confirm subscription unsubscribeChannel?: string; subscribeChannel?: string; // subscribing to channelexport interface WebSocketMessage {```TypeScriptThe JSON object can have any of these properties:UDN is based on WebSockets sending JSON strings.## The Manual WayFor TypeScript-based projects, you can use the [udn-frontend](https://github.com/marlon-erler/udn-frontend) package to manage the connection. This project provides methods for connecting/disconnecting, subscribing/unsubscribing, and sending messages. If you want to/need to implement this yourself, follow the manual instructions.**Base**## The Recommended Way- Make sure to label these channels as primary and secondary (you may translate these along with the rest of your app) as users are instructed on these terms.- Subscribe only to the primary channel, send on the primary and all secondary channels.- When supporting networks with multiple servers, differentiate between primary and secondary channels according to the explanation above.## Guidelines# App Developer's Guide---- Configure the TLS-enabled servers to connect to those without TLS; connecting vice-versa may not work.- Therefore, you should have at least one TLS-enabled server, and at least one server without TLS.- In case your clients need to use `http`-served apps, these apps may refuse to connect to TLS-enabled servers.- If you are using self-signed certificates, your servers may refuse to connect to other TLS-enabled servers.- Decide on one secondary channel for your network, configure all servers to subscribe, and make sure your users know this channel.- You should make sure to evenly distribute your clients to different servers, so give your clients addresses of different servers to avoid everybody using the same one.- Servers will attempt to restore lost connections to other servers periodically.- Server-to-server-connections are bidirectional, so connecting server A to server B yields the same output as connecting server B to server A.As explained in the _How it works_ section, you may want to use multiple servers on your network. In this case, consider the following:Use the code example given above for reference.2. Add secondary channels to the `subscribedChannels` array in the configuration file.1. Add the WebSocket addresses of servers you want to connect to the `connectFFor the imprint field, enter a url.Use `\n` to separate lines in the privacy policy.```} ] "secondary-channel-2" "secondary-channel-1", "subscribedChannels": [ ], "wss://192.168.0.200:3000" "ws://192.168.0.100:3000", "connectedServers": [ "port": 3000,{```JSONThe port and channels are self-explanatory. For servers, you'll need to provide full addresses:```} "subscribedChannels": [] "connectedServers": [], "imprint": "", "privacy": "", "port": 3000,{```JSONadRN32'&Ó
Ò
Â
Á
Ñ Ð Ø
×
Æ
Å
| { ©¨¢ˆ‡U'&õÈÇé¨zLKGF/. æÔ¿¾�`N98öÔ­©¨êéÆÅFEA@('©¨z9úЙ˜‡†RBy default, the configuration file looks like this:## Configuration5. A configuration file will be created automatically.4. Start the server with `bun run start`.3. Run `bun add @vdmdi/udn` to install the UDN server package.2. Create a directory for your server and open it in a terminal.1. Make sure bun is installed on your server.The UDN project is based on [bun](https://bun.sh/), a faster and more streamlined alternative to node.js.## Getting Started# Administrator's Guide---As you can see, there are many ways to connect multiple servers and communicate across them, all with their own pros and cons.We could now add a third server, connect it to at least one of S1 and S2, configure it to subscribe to the same secondary channel, and thereby extend the network further. We could also create another secondary channel like "s2-and-s3" and expect John to send his stuff on all thee channels.This requires John to know of "s1-and-s2" and, obviously, Bob to subscribe to "car-warranty". Jane and Alice could agree on their own primary channel and use "s1-and-s2" just like John did.```( - "car-warranty" )( - "s1-and-s2" )**S2** --("hello" on: )-> **Bob**Bob subscribed to "car-warranty", so S2 sends this message to Bob( - "car-warranty" )( - "s1-and-s2" )**S1** --("hello" on: )-> **S2**S2 subscribed to "s1-and-s2", so S1 sends this message to S2( - "car-warranty" )( - "s1-and-s2" )**John** --("hello" on: )-> **S1**John sends the message to his server# Sending the Message:---**S2** --(subscribe to "s1-and-s2" )-> **S1****S1** --(subscribe to "s1-and-s2" )-> **S2**# The servers subscribe:---**Bob** <-(subscription confirmed )-- **S2****Bob** --(subscribe to "car-warranty")-> **S2****John** <-(subscription confirmed )-- **S1****John** --(subscribe to "car-warranty")-> **S1**# John and Bob subscribe:```mdThen, John will send his messages on both "s1-and-s2" and "car-warranty". As always, his server will forward this message to every device subscribing to either of the channels. So the transfer would look like:As said previously, a message can be sent on multiple channels. One of them is the primary channel describing the topic of the chat, every other channel is called secondary. Instead of adding primary channels to our server configs, we'll decide on a secondary channel, for example "s1-and-s2". This needs to be set up only once.**The good way**They would then have to reconfigure S1 and S2 to also subscribe to this new primary channel, restart the servers to load the new config, and then start messaging. That would be a lot of effort, and it would have to be repeated for every new topic.We could simply tell John, Bob, S1, and S2 to subscribe to "car-warranty", a primary channel (it describes the topic of the chat). What if Alice and Jane want to chat as well? In this setup, they'd have to use the "car-warranty" channel too, because anything else will not be sent to the other server. But that would interrupt John's highly important business. Also, Alice and Jane don't care about Bob's car, so they should create their own primary channel describing their conversation anyway.**The bad way**John and Alice have set up their own UDN server, called S1. Their neighbors, Jane and Bob, did the same, we'll call their server S2. In this scenario, John can chat with Alice, and Jane can chat with Bob. But what if John wants reach Bob about his car's extended warranty? To achieve this, we need to first connect S1 and S2.**Scenario**## ExampleIt would be highly impractical to make every server subscribe to every primary channel there is. So instead, we utilize the fact that users can send on multiple channels. Let's explore this in an example:ad¢¾¾
™
•
”