Interacting with TLS/SSL WebSockets (WSS) in Fusion 2.5 - Is there a way?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello everyone,

    I am working on a piece of software that would interact with Twitch's EventSub API, which is polled using SSL websockets (wss).

    Is there a straightforward way to do it? I tried using MooSock but I couldn't even get a proper handshake working, let alone implementing the whole WSS protocol...

    I also know there is a WebSocket extension for the HTML5 runtime, but my software will run the normal Windows runtime (and requires several extensions that are not HTML5-compatible, among which WinMessPro and DLL Object).

    Any other idea? Alternatively, a different - easier - way to interact with Twitch EventSub?

    Thanks in advance.
    Azrael

  • OK I might have found a way. I'm trying to cook with DLL Object and winhttp.dll, which is a native Windows DLL that natively supports websockets.
    The main issue is winhttp is one of the few Windows API that expects UTF-16 through and through. Meanwhile, I think DLL Object tries to send ANSI-encoded data.

    So far the only solution I found is to use Phi's UTF-16 extension, which doesn't store UTF-16 data in either its own or Fusion's variables but directly in memory, so I have to allocate memory with Memory Object and store pointers in my variables. This is absurdly painful... But heh, I'm learnding I guess...

    Still, if someone has an easier way, I'm all ears.

  • Try this new Unicode version of the DLL objet, hopefully I had the latest source code of the object.

    Changes:

    There is a new property and a new action to specify if the functions use unicode strings (by default the property is off for old MFAs and on when you insert a new DLL object).

    Be careful, if you save a MFA after installing this object, then you won't be able to load the MFA later with the old version of the object (if you want to uninstall the new object for some reason, bug, etc). So keep a copy of your current MFA.

  • Some news from the frontline:

    I have given up on using winhttp.dll. Too complicated and I was never able to even get a working GET request.

    I elected to use libcurl.dll instead. I have finally reached a point where I can have a working websocket session and subscribe to a first event by calling an endpoint. My main issue right now is that the server keeps disconnecting me and it is very hard to debug because disconnection codes are typically sent in the metadata of the websocket frame rather than the payload, which libcurl returns as a C structure in a buffer. Unfortunately, even with Memory Object to poke at the buffer, reading a C structure in Fusion is proving challenging, to say the least...

    Edit: It seems being less agressive about using curl_ws_recv solves the disconnection problem. Still, not being able to process ws frame metadata might prove problematic in the future.

    Edit2: No it doesn't, though it does take longer to disconnect. Weird... and hard to debug.

  • Okay, well, it's crude, but it's working! I actually have a functioning bot that subscribes to Twitch events and reacts to those I want it to, based mostly on libcurl.dll for websockets and POST endpoints, MooSock for the IRC part of the API, GET Object for receiving a user token, Memory Object to handle buffers, and JSON Object to parse the events.

    I don't plan on distributing it for the time being but if someone ever Google this, finds this post and needs help doing the same, send me a message and I'll be happy to help!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!