use typescript optional properties.

This commit is contained in:
Miroslav Šedivý 2021-07-17 14:08:25 +02:00
parent ad7e3d47c5
commit 2c70093d77
5 changed files with 29 additions and 29 deletions

View File

@ -34,10 +34,10 @@ export interface NekoEvents {
['session.updated']: (id: string) => void ['session.updated']: (id: string) => void
// room events // room events
['room.control.host']: (hasHost: boolean, hostID: string | undefined) => void ['room.control.host']: (hasHost: boolean, hostID?: string) => void
['room.screen.updated']: (width: number, height: number, rate: number) => void ['room.screen.updated']: (width: number, height: number, rate: number) => void
['room.clipboard.updated']: (text: string) => void ['room.clipboard.updated']: (text: string) => void
['room.broadcast.status']: (isActive: boolean, url: string | undefined) => void ['room.broadcast.status']: (isActive: boolean, url?: string) => void
} }
export class NekoMessages extends EventEmitter<NekoEvents> { export class NekoMessages extends EventEmitter<NekoEvents> {

View File

@ -16,7 +16,7 @@ export interface WebRTCStats {
fps: number fps: number
width: number width: number
height: number height: number
muted: boolean | undefined muted?: boolean
} }
export interface ICEServer { export interface ICEServer {

View File

@ -1,7 +1,7 @@
import { ICEServer } from '../internal/webrtc' import { ICEServer } from '../internal/webrtc'
export interface Message { export interface Message {
event: string | undefined event?: string
payload: any payload: any
} }
@ -10,12 +10,12 @@ export interface Message {
///////////////////////////// /////////////////////////////
export interface SystemWebRTC { export interface SystemWebRTC {
event: string | undefined event?: string
videos: string[] videos: string[]
} }
export interface SystemInit { export interface SystemInit {
event: string | undefined event?: string
session_id: string session_id: string
control_host: ControlHost control_host: ControlHost
screen_size: ScreenSize screen_size: ScreenSize
@ -26,13 +26,13 @@ export interface SystemInit {
} }
export interface SystemAdmin { export interface SystemAdmin {
event: string | undefined event?: string
screen_sizes_list: ScreenSize[] screen_sizes_list: ScreenSize[]
broadcast_status: BroadcastStatus broadcast_status: BroadcastStatus
} }
export interface SystemDisconnect { export interface SystemDisconnect {
event: string | undefined event?: string
message: string message: string
} }
@ -41,23 +41,23 @@ export interface SystemDisconnect {
///////////////////////////// /////////////////////////////
export interface SignalProvide { export interface SignalProvide {
event: string | undefined event?: string
sdp: string sdp: string
iceservers: ICEServer[] iceservers: ICEServer[]
video: string video: string
} }
export interface SignalCandidate extends RTCIceCandidateInit { export interface SignalCandidate extends RTCIceCandidateInit {
event: string | undefined event?: string
} }
export interface SignalAnswer { export interface SignalAnswer {
event: string | undefined event?: string
sdp: string sdp: string
} }
export interface SignalVideo { export interface SignalVideo {
event: string | undefined event?: string
video: string video: string
} }
@ -66,12 +66,12 @@ export interface SignalVideo {
///////////////////////////// /////////////////////////////
export interface SessionID { export interface SessionID {
event: string | undefined event?: string
id: string id: string
} }
export interface MemberProfile { export interface MemberProfile {
event: string | undefined event?: string
id: string id: string
name: string name: string
is_admin: boolean is_admin: boolean
@ -83,14 +83,14 @@ export interface MemberProfile {
} }
export interface SessionState { export interface SessionState {
event: string | undefined event?: string
id: string id: string
is_connected: boolean is_connected: boolean
is_watching: boolean is_watching: boolean
} }
export interface SessionData { export interface SessionData {
event: string | undefined event?: string
id: string id: string
profile: MemberProfile profile: MemberProfile
is_connected: boolean is_connected: boolean
@ -102,28 +102,28 @@ export interface SessionData {
///////////////////////////// /////////////////////////////
export interface ControlHost { export interface ControlHost {
event: string | undefined event?: string
has_host: boolean has_host: boolean
host_id: string | undefined host_id: string | undefined
} }
// TODO: New. // TODO: New.
export interface ControlMove { export interface ControlMove {
event: string | undefined event?: string
x: number x: number
y: number y: number
} }
// TODO: New. // TODO: New.
export interface ControlScroll { export interface ControlScroll {
event: string | undefined event?: string
x: number x: number
y: number y: number
} }
// TODO: New. // TODO: New.
export interface ControlKey { export interface ControlKey {
event: string | undefined event?: string
key: number key: number
} }
@ -132,7 +132,7 @@ export interface ControlKey {
///////////////////////////// /////////////////////////////
export interface ScreenSize { export interface ScreenSize {
event: string | undefined event?: string
width: number width: number
height: number height: number
rate: number rate: number
@ -143,7 +143,7 @@ export interface ScreenSize {
///////////////////////////// /////////////////////////////
export interface ClipboardData { export interface ClipboardData {
event: string | undefined event?: string
text: string text: string
} }
@ -152,14 +152,14 @@ export interface ClipboardData {
///////////////////////////// /////////////////////////////
export interface KeyboardModifiers { export interface KeyboardModifiers {
event: string | undefined event?: string
caps_lock: boolean caps_lock: boolean
num_lock: boolean num_lock: boolean
scroll_lock: boolean scroll_lock: boolean
} }
export interface KeyboardMap { export interface KeyboardMap {
event: string | undefined event?: string
layout: string layout: string
variant: string variant: string
} }
@ -169,7 +169,7 @@ export interface KeyboardMap {
///////////////////////////// /////////////////////////////
export interface BroadcastStatus { export interface BroadcastStatus {
event: string | undefined event?: string
is_active: boolean is_active: boolean
url: string | undefined url: string | undefined
} }
@ -179,7 +179,7 @@ export interface BroadcastStatus {
///////////////////////////// /////////////////////////////
export interface SendMessage { export interface SendMessage {
event: string | undefined event?: string
sender: string sender: string
subject: string subject: string
body: string body: string

View File

@ -32,7 +32,7 @@ export interface WebRTCStats {
fps: number fps: number
width: number width: number
height: number height: number
muted: boolean | undefined muted?: boolean
} }
///////////////////////////// /////////////////////////////

View File

@ -39,12 +39,12 @@ export interface ReconnecterConfig {
export class Reconnecter extends EventEmitter<ReconnecterEvents> { export class Reconnecter extends EventEmitter<ReconnecterEvents> {
private _conn: ReconnecterAbstract private _conn: ReconnecterAbstract
private _config: ReconnecterConfig private _config: ReconnecterConfig
private _timeout: number | undefined private _timeout?: number
private _open = false private _open = false
private _connected = false private _connected = false
private _total_reconnects = 0 private _total_reconnects = 0
private _last_connected: Date | undefined private _last_connected?: Date
constructor(conn: ReconnecterAbstract, config?: ReconnecterConfig) { constructor(conn: ReconnecterAbstract, config?: ReconnecterConfig) {
super() super()