@@ -3,6 +3,7 @@ import { getActions } from './actions.js'
33import { getPresets } from './presets.js'
44import { getVariables , updateVariables } from './variables.js'
55import { getFeedbacks } from './feedbacks.js'
6+ import { upgradeScripts } from './upgrades.js'
67
78import WebSocket from 'ws'
89
@@ -47,11 +48,31 @@ class VDONinjaInstance extends InstanceBase {
4748 label : 'API ID' ,
4849 width : 6 ,
4950 } ,
51+ {
52+ type : 'checkbox' ,
53+ id : 'wsCustom' ,
54+ label : 'Custom Websockets Server (Advanced)' ,
55+ default : false ,
56+ width : 6 ,
57+ } ,
58+ {
59+ type : 'textinput' ,
60+ id : 'wsServer' ,
61+ label : 'Custom Websockets Server Domain' ,
62+ default : 'api.vdo.ninja' ,
63+ tooltip :
64+ 'Only use this if you are self-hosting your own websockets server. Only include the domain, not "wss://" or port' ,
65+ width : 6 ,
66+ isVisible : ( options ) => options . wsCustom ,
67+ } ,
5068 ]
5169 }
5270
5371 async configUpdated ( config ) {
5472 this . config = config
73+ if ( this . reconnect ) {
74+ clearInterval ( this . reconnect )
75+ }
5576 this . initWebSocket ( )
5677 }
5778
@@ -85,7 +106,12 @@ class VDONinjaInstance extends InstanceBase {
85106 delete this . ws
86107 }
87108
88- this . ws = new WebSocket ( `wss://api.vdo.ninja:443` )
109+ let serverUrl = 'api.vdo.ninja'
110+ if ( this . config . wsCustom && this . config . wsServer ) {
111+ serverUrl = this . config . wsServer
112+ }
113+
114+ this . ws = new WebSocket ( `wss://${ serverUrl } :443` )
89115
90116 this . ws . on ( 'open' , ( ) => {
91117 if ( ! this . connected ) {
@@ -115,7 +141,7 @@ class VDONinjaInstance extends InstanceBase {
115141 this . connected = false
116142 this . updateStatus ( 'connection_failure' )
117143 if ( data ?. code == 'ENOTFOUND' ) {
118- this . log ( 'error' , `Unable to reach api.vdo.ninja ` )
144+ this . log ( 'error' , `Unable to reach ${ serverUrl } ` )
119145 } else {
120146 this . log ( 'error' , `WebSocket ${ data } ` )
121147 }
@@ -251,4 +277,4 @@ class VDONinjaInstance extends InstanceBase {
251277 }
252278}
253279
254- runEntrypoint ( VDONinjaInstance , [ ] )
280+ runEntrypoint ( VDONinjaInstance , upgradeScripts )
0 commit comments