mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-16 05:43:24 +00:00
Add ServiceHost, ServiceClient, and RondevuService for high-level service management
- Add RondevuService: High-level API for username claiming and service publishing with Ed25519 signatures - Add ServiceHost: Manages offer pool for hosting services with auto-replacement - Add ServiceClient: Connects to hosted services with automatic reconnection - Add NoOpSignaler: Placeholder signaler for connection setup - Integrate Ed25519 signature functionality from @noble/ed25519 - Add ESLint and Prettier configuration with 4-space indentation - Add demo with local signaling test - Version bump to 0.10.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
44
src/types.ts
44
src/types.ts
@@ -1,34 +1,42 @@
|
||||
/**
|
||||
* Core connection types
|
||||
*/
|
||||
import {EventBus} from "./event-bus";
|
||||
import {Binnable} from "./bin";
|
||||
import { EventBus } from './event-bus.js'
|
||||
import { Binnable } from './bin.js'
|
||||
|
||||
export type Message = string | ArrayBuffer;
|
||||
export type Message = string | ArrayBuffer
|
||||
|
||||
export interface QueueMessageOptions {
|
||||
expiresAt?: number;
|
||||
expiresAt?: number
|
||||
}
|
||||
|
||||
export interface ConnectionEvents {
|
||||
'state-change': ConnectionInterface['state']
|
||||
'message': Message;
|
||||
message: Message
|
||||
}
|
||||
|
||||
export interface ConnectionInterface {
|
||||
id: string;
|
||||
host: string;
|
||||
service: string;
|
||||
state: 'connected' | 'disconnected' | 'connecting';
|
||||
lastActive: number;
|
||||
expiresAt?: number;
|
||||
events: EventBus<ConnectionEvents>;
|
||||
export const ConnectionStates = ['connected', 'disconnected', 'connecting'] as const
|
||||
|
||||
queueMessage(message: Message, options?: QueueMessageOptions): Promise<void>;
|
||||
sendMessage(message: Message): Promise<boolean>;
|
||||
export const isConnectionState = (state: string): state is (typeof ConnectionStates)[number] =>
|
||||
ConnectionStates.includes(state as any)
|
||||
|
||||
export interface ConnectionInterface {
|
||||
id: string
|
||||
service: string
|
||||
state: (typeof ConnectionStates)[number]
|
||||
lastActive: number
|
||||
expiresAt?: number
|
||||
events: EventBus<ConnectionEvents>
|
||||
|
||||
queueMessage(message: Message, options?: QueueMessageOptions): Promise<void>
|
||||
sendMessage(message: Message): Promise<boolean>
|
||||
}
|
||||
|
||||
export interface Signaler {
|
||||
addIceCandidate(candidate: RTCIceCandidate): Promise<void> | void;
|
||||
addListener(callback: (candidate: RTCIceCandidate) => void): Binnable;
|
||||
}
|
||||
addIceCandidate(candidate: RTCIceCandidate): Promise<void> | void
|
||||
addListener(callback: (candidate: RTCIceCandidate) => void): Binnable
|
||||
addOfferListener(callback: (offer: RTCSessionDescriptionInit) => void): Binnable
|
||||
addAnswerListener(callback: (answer: RTCSessionDescriptionInit) => void): Binnable
|
||||
setOffer(offer: RTCSessionDescriptionInit): Promise<void>
|
||||
setAnswer(answer: RTCSessionDescriptionInit): Promise<void>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user