UNPKG

@lakshyashukla/nexora-sdk

Version:

SDK for 1:1 chat and video calling

107 lines (99 loc) 2.56 kB
import React from 'react'; interface ChatProps { userId: string; threadId?: string; receiverId: string; serverUrl: string; } interface VideoCallProps { /** * ID of the current user */ userId: string; /** * ID of the user being called */ receiverId: string; /** * URL for the WebSocket server */ serverUrl: string; /** * Display name for the current user * @default "You" */ userName?: string; /** * Display name for the user being called * @default "User" */ receiverName?: string; /** * Callback triggered when a call is successfully started */ onCallStarted?: () => void; /** * Callback triggered when a call ends */ onCallEnded?: () => void; /** * Callback for handling errors during call setup or execution */ onError?: (error: Error) => void; } interface Message { id: string; content: string; senderId: string; receiverId: string; timestamp: number; } interface ChatConfig { userId: string; serverUrl: string; onMessageReceived?: (message: Message) => void; } interface VideoCallConfig$1 { userId: string; serverUrl: string; onCallReceived?: (callerId: string) => void; onCallEnded?: () => void; } declare class ChatService { private socket; private config; constructor(config: ChatConfig); private initialize; sendMessage(receiverId: string, content: string): Promise<boolean>; disconnect(): void; } interface VideoCallConfig { userId: string; serverUrl: string; onCallEnded?: () => void; onCallReceived?: (callerId: string) => void; } declare class VideoService { private socket; private peerConnection; private config; private localStream; private remoteStream; constructor(config: VideoCallConfig); private initialize; private setupPeerConnection; startCall(receiverId: string): Promise<void>; private handleOffer; private handleAnswer; private handleIceCandidate; endCall(): void; getLocalStream(): MediaStream | null; getRemoteStream(): MediaStream | null; disconnect(): void; } interface WithApiKeyProps { apiKey: string; } declare const Chat: React.FC<ChatProps & WithApiKeyProps>; declare const VideoCall: React.FC<VideoCallProps & WithApiKeyProps>; export { Chat, ChatConfig, ChatProps, ChatService, Message, VideoCall, VideoCallConfig$1 as VideoCallConfig, VideoCallProps, VideoService, WithApiKeyProps };