UNPKG

callskit

Version:

A toolkit for building call experience using Cloudflare Realtime

57 lines (51 loc) 1.44 kB
import * as Party from 'partykit/server'; export { routePartyTracksRequest as routeApiRequest } from 'partytracks/server'; type ChatMessagePayload = { type: 'text'; message: string; } | { type: 'image' | 'file'; name: string; url: string; size: number; }; type ChatBaseMessage = { id: string; user_id: string; display_name: string; created_at: Date; }; type ChatTextMessage = ChatBaseMessage & ChatMessagePayload; type ChatImageMessage = ChatBaseMessage & { type: 'image'; url: string; size: number; }; type ChatMessage = ChatTextMessage | ChatImageMessage; interface SerializedUser { id: string; name: string; micEnabled: boolean; micTrackId?: string; cameraEnabled: boolean; cameraTrackId?: string; screenshareEnabled: boolean; screenshareVideoTrackId?: string; screenshareAudioTrackId?: string; } interface User extends SerializedUser { connectionId: string; } declare class PartyKitServer implements Party.Server { readonly room: Party.Room; started_at: Date; connectionIds: string[]; users: Map<string, User>; chat: ChatMessage[]; constructor(room: Party.Room); onStart(): Promise<void>; onConnect(conn: Party.Connection, ctx: Party.ConnectionContext): void; onClose(connection: Party.Connection): Promise<void>; onMessage(message: string, sender: Party.Connection): void; } export { PartyKitServer };