teoclits
Version:
Typescript angular Teonet Client module
182 lines (181 loc) • 5.03 kB
TypeScript
import Teocli from 'teocli/teocli';
import 'webrtc-adapter';
export declare class TeocliRTCMap {
private t;
private map;
private cli;
constructor(t: any);
/**
* Create new key in map
*/
create(key: string, pc: any, channel?: any, data?: any): void;
/**
* Add connected channel to map
*/
add(key: string, channel: any, data?: any): void;
/**
* Check if key exist (and connection with key established)
*/
exist(key: string): boolean;
/**
* Check if key exist and connection with this peer established
*/
connected(key: string): boolean;
/**
* Get reference to data channel (connection)
*/
getChannel(key: string): any;
/**
* Get reference to connection
*/
getConn(key: string): any;
/**
* Delete keys channel
*/
deleteChannel(key: string): void;
/**
* Delete key and all it services (channel) from the map
*/
delete(key: string): void;
/**
* Delete all keys
*/
deleteAll(): void;
/**
* Get pointer to map
*/
getMap(): any;
}
export declare type CallOptionsType = {
video: boolean;
audio: boolean;
chat: boolean;
};
export declare class TeocliRTCSignalingChannel extends Teocli {
protected client_name: string;
protected map: TeocliRTCMap;
protected oncandidate: (peer: string) => void;
protected onrtcmessage: (peer: string, evt: any) => void;
/**
* Start peer connection - Create new key in the RTC map
*/
protected startConnection(peer: string, pc: any): void;
/**
* Get existing connection from RTC map
*/
protected getConnection(peer: string): any;
/**
* Set peer channel connected - Update key in the RTC map
*/
protected setConnected(peer: string, channel: any): void;
/**
* Remove peer from RTC map
*/
protected removeConnection(peer: string): void;
/**
* Send RTC signal command
*/
protected sendRTC(peer: string, msg: any): void;
/**
* Get WebRTC map
* @return {any} Pointer to Teonet WebRTC map
*/
getWebRTCMap(): any;
/**
* Is peer connected and is online
*/
isWebRTConline(key: string): boolean;
/**
* Process RTC command (cmd = 255)
*/
onrtc(err: any, p: any): number;
/**
* Send teonet message by Teocli or WebRTC
*/
send(data: any): boolean;
/**
* Destroy all connections.
* Interception Send event to Event Subscribers
*
* @param {string} ev Event name
* @param {object[]) ...obj Objects send to subscribers
*/
sendEvent(ev: string, ...obj: object[]): void;
/**
* Convert WebRTCNap to Array
*/
webrtcToAr(webrtc?: any): {
key: string;
data: any;
}[];
}
export declare class TeocliRTC extends TeocliRTCSignalingChannel {
private configuration;
private callAnswer;
private nodisconnect_flg;
/**
* TeocliRTC class constructor
*/
constructor(ws: WebSocket);
/**
* Connect to remote peer
*/
private connect(peer);
/**
* Process remote peer RTC signal messages
*/
private processRemoteMessage(peer, evt);
/**
* Create connection between this peer and remote peer
*
* @param {string} peer Remote peer name
*/
private createConnection(peer, isInitiator?);
/**
* Add stream to RTCConnection
*
* @param {any} Reference to RTCPeerConnection
* @param {any} Stream to add to connection
* @param {any} Options with tracks type (video or audio) to add. If options
* is ommited than all strean tracks will be added
*/
protected addStream(pc: any, stream: any, options?: any): void;
/**
* Show error
*
* @param {name: string, nessage: string} error Error to show in console
*/
private logError(error);
/**
* Make Call to remote peer
*
* @param {string} peer Peer name
* @param {CallOptionsType} options Options:
* video - reqiest video,
* audio - request audio,
* chat - request chat channel
*
* @return {boolean} true if call send to remotepeer;
* false if peer name empty,
* or peer not connected to this host,
* or wrong options send (all: video, audio and
* channel is false)
*/
call(peer: string, localStream?: any, options?: CallOptionsType): boolean;
/**
* Hangup call
*/
hangup(peer: string): void;
/**
* Register remote call answer
*/
registerCallAnswer(callAnswer: any): void;
/**
* Remove all senders (all senders media tracks) from connection
*/
removeTracks(peer: string): void;
/**
* Unregister remote call answer
*/
unRegisterCallAnswer(): void;
}