(immediate: boolean = false)
| 92 | // Make sure we always force a full disconnect before reconnecting |
| 93 | if (prop === 'connect') { |
| 94 | return async () => { |
| 95 | try { |
| 96 | await target.disconnect(); |
| 97 | status.value = 'CONNECTING'; |
| 98 | await target.connect(); |
| 99 | } catch (e) {} |
| 100 | }; |
| 101 | } |
| 102 | return Reflect.get(target, prop, receiver); |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | async function _init(immediate: boolean = false) { |
| 107 | if (clientRef.value) { |
| 108 | await disconnect(); |
| 109 | clientRef.value = undefined; |
| 110 | } |
| 111 | console.debug('Initializing Streamer.bot Client...'); |
| 112 | |
| 113 | if (immediate) status.value = 'CONNECTING'; |
| 114 | |
| 115 | _client = new Proxy( |
| 116 | new StreamerbotClient({ |
| 117 | scheme: toValue(_options.value.scheme) || 'ws', |
| 118 | host: toValue(_options.value.host) || '127.0.0.1', |
| 119 | port: toValue(_options.value.port) || 8080, |
| 120 | endpoint: toValue(_options.value.endpoint) || '/', |
| 121 | password: toValue(_options.value.password) || '', |
| 122 | immediate: immediate, |
| 123 | subscribe: toValue(_options.value.subscribe), |
no test coverage detected