export const nullDevice = { id : '' , sharingSessionID : '' , deviceOS : '' , deviceType : '' , deviceIP : '' , deviceBrowser : '' , deviceScreenWidth : - 1 , deviceScreenHeight : - 1 , } ; class ConnectedDevices { devices : Device [ ] = [ ] ; pendingConnectionDevice : Device = nullDevice ; pendingDeviceConnectedListeners : ( ( device : Device ) => void ) [ ] = [ ] ; resetPendingConnectionDevice ( ) { this . pendingConnectionDevice = nullDevice ; } getDevices ( ) { return this . devices ; } removeAllDevices ( ) { this . devices = [ ] as Device [ ] ; } removeDeviceByID ( deviceIDToRemove ) { return new Promise < undefined > ( ( resolve ) => { this . devices = this . devices . filter ( ( d ) => { return d . id !== deviceIDToRemove ; } ) ; resolve ( undefined ) ; } ) ; } addDevice ( device ) { this . devices . push ( device ) ; } addPendingConnectedDeviceListener ( callback ) { this . pendingDeviceConnectedListeners . push ( callback ) ; } setPendingConnectionDevice ( device ) { this . pendingConnectionDevice = device ; this . emitPendingConnectionDeviceConnected ( ) ; } emitPendingConnectionDeviceConnected ( ) { this . pendingDeviceConnectedListeners . forEach ( ( callback ) => { callback ( this . pendingConnectionDevice ) ; } ) ; } } export default ConnectedDevices ;