import { NodeCG } from "nodecg-types/types/server" ; import { success , ServiceBundle , Logger } from "nodecg-io-core" ; import { StreamElementsServiceClient } from "./StreamElements" ; interface StreamElementsServiceConfig { jwtToken : string ; handleTestEvents : boolean ; } export { StreamElementsServiceClient } from "./StreamElements" ; module . exports = ( nodecg ) => { const schemaPath = [ __dirname , "../streamelements-schema.json" ] ; new StreamElementsService ( nodecg , "streamelements" , ... schemaPath ) . register ( ) ; } ; class StreamElementsService extends ServiceBundle < StreamElementsServiceConfig , StreamElementsServiceClient > { async validateConfig ( config ) { return new StreamElementsServiceClient ( config . jwtToken , config . handleTestEvents ) . testConnection ( ) ; } async createClient ( config , logger ) { logger . info ( "Connecting to StreamElements socket server..." ) ; const client = new StreamElementsServiceClient ( config . jwtToken , config . handleTestEvents ) ; await client . connect ( ) ; logger . info ( "Successfully connected to StreamElements socket server." ) ; return success ( client ) ; } stopClient ( client ) { client . close ( ) ; } removeHandlers ( client ) { client . removeAllListeners ( ) ; } }