| 13 | export class App { |
| 14 | |
| 15 | constructor(options?) { |
| 16 | let defaultOptions = { |
| 17 | cipherAlgorithm: defaultCipherAlgorithm, |
| 18 | password: defaultPassword, |
| 19 | port: defaultServerPort, |
| 20 | timeout: 10, |
| 21 | expireTime: undefined, |
| 22 | disableSelfProtection: false, |
| 23 | speed: NaN |
| 24 | }; |
| 25 | |
| 26 | options = options || defaultOptions; |
| 27 | Object.getOwnPropertyNames(defaultOptions).forEach(n => options[n] = options[n] || defaultOptions[n]); |
| 28 | |
| 29 | let server = new LsServer(options); |
| 30 | server.start(); |
| 31 | server.once('close', () => App.Users.delete(options.port)); |
| 32 | |
| 33 | App.Users.set(options.port, server); |
| 34 | } |
| 35 | |
| 36 | public static Users = new Map<number, LsServer>(); |
| 37 | |