Add regional channel routing (closes #42)

This commit is contained in:
Jack Kingsman
2026-03-09 11:09:31 -07:00
parent 0c5b37c07c
commit 811c7e7349
18 changed files with 604 additions and 61 deletions
+5 -1
View File
@@ -1,5 +1,5 @@
import { useEffect, useRef, useCallback } from 'react';
import type { HealthStatus, Contact, Message, MessagePath, RawPacket } from './types';
import type { Channel, HealthStatus, Contact, Message, MessagePath, RawPacket } from './types';
interface WebSocketMessage {
type: string;
@@ -21,6 +21,7 @@ interface UseWebSocketOptions {
onMessage?: (message: Message) => void;
onContact?: (contact: Contact) => void;
onContactDeleted?: (publicKey: string) => void;
onChannel?: (channel: Channel) => void;
onChannelDeleted?: (key: string) => void;
onRawPacket?: (packet: RawPacket) => void;
onMessageAcked?: (messageId: number, ackCount: number, paths?: MessagePath[]) => void;
@@ -105,6 +106,9 @@ export function useWebSocket(options: UseWebSocketOptions) {
case 'contact':
handlers.onContact?.(msg.data as Contact);
break;
case 'channel':
handlers.onChannel?.(msg.data as Channel);
break;
case 'contact_deleted':
handlers.onContactDeleted?.((msg.data as { public_key: string }).public_key);
break;