@@ -5,6 +5,7 @@ import OBSWebSocket from "obs-websocket-js";
55interface OBSServiceConfig {
66 host : string ;
77 port : number ;
8+ isSecure ?: boolean ;
89 password ?: string ;
910}
1011
@@ -18,7 +19,7 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
1819 async validateConfig ( config : OBSServiceConfig ) : Promise < Result < void > > {
1920 const client = new OBSWebSocket ( ) ;
2021 try {
21- await client . connect ( { address : ` ${ config . host } : ${ config . port } ` , password : config . password } ) ;
22+ await this . connectClient ( client , config ) ;
2223
2324 client . disconnect ( ) ;
2425 } catch ( e ) {
@@ -30,7 +31,7 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
3031 async createClient ( config : OBSServiceConfig , logger : Logger ) : Promise < Result < OBSServiceClient > > {
3132 const client = new OBSWebSocket ( ) ;
3233 try {
33- await client . connect ( { address : ` ${ config . host } : ${ config . port } ` , password : config . password } ) ;
34+ await this . connectClient ( client , config ) ;
3435 logger . info ( "Connected to OBS successfully." ) ;
3536 } catch ( e ) {
3637 return error ( e . error ) ;
@@ -39,6 +40,11 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
3940 return success ( client ) ;
4041 }
4142
43+ private async connectClient ( client : OBSWebSocket , config : OBSServiceConfig ) : Promise < void > {
44+ const protocol = config . isSecure ? "wss" : "ws" ;
45+ await client . connect ( `${ protocol } ://${ config . host } :${ config . port } ` , config . password ) ;
46+ }
47+
4248 stopClient ( client : OBSServiceClient ) {
4349 client . disconnect ( ) ;
4450 }
0 commit comments