The app has a button with the following function as a click handler
const doChatStuff = ( ) => {
const clientId = '123' ;
const nick = 'twitch_name' ;
const url = `https://id.twitch.tv/oauth2/authorize?client_id=${ clientId } &redirect_uri=slobs-oauth://jingle_punks&response_type=token&scope=chat:edit&scope=chat:read` ;
try {
window . streamlabsOBS . v1 . Authorization . showAuthorizationWindow (
url , { width : 600 , height : 800 } ,
event => {
if ( event . type === 'auth_redirect' ) {
const token = parseTokenFromUrl ( event . url ) ;
window . Streamlabs . twitch . initTwitchChat ( { nick, token } )
window . Streamlabs . sendChatMessage ( 'Hello World!' )
}
}
) ;
} catch ( e ) {
console . error ( `Twitch auth FAILED:` , e )
}
}
after clicking this button, the following error appears in the console:
client.js:2259 You've enabled twitch chat feature, but onChatMessage handler not found. Implement it to receive messages.
r @ client.js:2259
value @ streamlabs-platform.min.js:1
_initTwitchChat @ streamlabs-platform.min.js:15
initTwitchChat @ streamlabs-platform.min.js:15
(anonymous) @ index.js:46
(anonymous) @ C:\Program Files\Streamlabs OBS\resources\app.asar\bundles\guest-api.js:1
emitTwo @ events.js:126
emit @ events.js:214
streamlabs-platform.min.js:1 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
at t.value (https://cdn.streamlabs.com/slobs-platform/lib/streamlabs-platform.min.js:1:47173)
at t.value (https://cdn.streamlabs.com/slobs-platform/lib/streamlabs-platform.min.js:1:49595)
at t._sendCallback (https://cdn.streamlabs.com/slobs-platform/lib/streamlabs-platform.min.js:15:5894)
at t.value (https://cdn.streamlabs.com/slobs-platform/lib/streamlabs-platform.min.js:15:2673)
at Object.c030ee30-d4ff-419b-acba-4e5b7ce3cf70 (http://localhost:8081/build/static/js/index.9622364c.chunk.js:1:64621)
at EventEmitter.<anonymous> (C:\Program Files\Streamlabs OBS\resources\app.asar\bundles\guest-api.js:1:6454)
at emitTwo (events.js:126:13)
at EventEmitter.emit (events.js:214:7)
value @ streamlabs-platform.min.js:1
value @ streamlabs-platform.min.js:1
_sendCallback @ streamlabs-platform.min.js:15
value @ streamlabs-platform.min.js:15
(anonymous) @ index.js:47
(anonymous) @ C:\Program Files\Streamlabs OBS\resources\app.asar\bundles\guest-api.js:1
emitTwo @ events.js:126
emit @ events.js:214
then another button is clicked with the following onClick handler:
( ) => window . Streamlabs . sendChatMessage ( 'Hello World!' )
clicking that button yields this error:
streamlabs-platform.min.js:1 WebSocket is already in CLOSING or CLOSED state.