feat(server): the relay joins modems of different projects by a code (K3)

A modem that offers a connection to another project is found by six
characters derived from its project and itself (modemCode): a copy of the
project has another code, so no two modems offer the same one. The room
names its modems of other projects to F's relay at a start and none at a
stop; the relay pairs each offer with the first modem that joins its code,
one to one as Java's server modem takes one client, and passes the frames
between the rooms' threads. Every client hears how each modem stands
(`modems`: connected, waiting, taken, unpaired, ambiguous, detached, or
unavailable without F). The document keeps the connection and the code.

Measured on F with two threads: a ping from one project's notebook to the
other's goes through; a third project that wants the same code reads
taken, and takes it when the second stops; a deleted project's modem
leaves with its room.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 18:24:19 +00:00
co-authored by Claude Opus 5.5
parent c85b0e45da
commit 7b943d3d96
15 changed files with 726 additions and 25 deletions
+18 -2
View File
@@ -19,9 +19,11 @@ import {
type HostLabelPolicy,
type ManualRoute,
type NodeKind,
type RemoteLinkRelay,
type RouteRow,
} from '@mdg-filius/core';
import { modemPort } from '@mdg-filius/fls';
import type { ModemConnection } from './settings.js';
import { inOrder, ROOTS } from './projectDoc.js';
import { fromY } from './values.js';
import { cardAddress, nodeLabel } from './view.js';
@@ -79,7 +81,12 @@ export interface SwitchSheet {
export interface ModemSheet {
readonly kind: 'remoteLink';
readonly name: string;
/** The pair in the project: two modems on one port. */
readonly port: number;
/** How it finds its partner (setModemConnection). */
readonly connection: ModemConnection;
/** Joining: the code of the modem it connects to ('' while none is given). */
readonly code: string;
}
/** A router's or home router's card. */
@@ -239,8 +246,17 @@ export function deviceSheet(doc: Y.Doc, id: string): DeviceSheet | undefined {
cloud: config?.get('showsAsCloud') === true,
};
}
case 'remoteLink':
return { kind, name, port: modemPort(setting(node, 'remoteLink')?.get('pairIdentifier') as string | undefined) };
case 'remoteLink': {
const config = setting(node, 'remoteLink');
const relay = fromY(config?.get('relay')) as RemoteLinkRelay | undefined;
return {
kind,
name,
port: modemPort(config?.get('pairIdentifier') as string | undefined),
connection: relay?.role ?? 'inProject',
code: relay?.role === 'join' ? relay.code : '',
};
}
case 'router': {
const interfaces = interfacesOf(doc, id, node);
const gateway = text(setting(node, 'device'), 'defaultGateway');