SyrinControl - WIP FoundryVTT module integration

Hi there!

For the last couple of days, I’ve been working on integrating Syrinscape Online with Foundry VTT. This tool only controls the Syrinscape Online via API you provided but does not stream sound.

I still find it very handy during my sessions, after all, it’s one less window to maintain, plus I can set a mood to a given scene and simply forget about it. Syrinscape will play right tone every time :slight_smile:

Please, keep in mind that this module is still in early-stages. Usable but very rough.

Meanwhile, I had to make a bypass for the CORS problem (referred many times in other topics). While making such a CORS proxy is possible for self-hosted games, it is going to be a huge pain for shared solutions like ForgeVTT which I use personally.
The authors of ForgeVTT do not want to add such a proxy and I can not blame them - it seems it should be fixed on the Syrinscape API side.

For now, I can still use my module on ForgeVTT by using dirty hack with CORS proxy on localhost docker container under NGINX proxy (for self-signed HTTPS certificate)…
But this is not the right way for an average GM.

I will be happy to cooperate with you and find a better solution.

1 Like

This looks pretty cool!

@Steve uses Foundry… we should be able to take a look! :smiley: :trophy: :beer:

@ryan.cassar or @sonofconan may be able to comment on the proxy stuff, and shed a bit of light.

This looks great, I shall give it a try in my next game! :grin:

Perfect! I hope we can make this integration smooth and awesome :slight_smile:

I made a bug fix release that solves a few issues but mainly, it sets the default synchronization method to the CSV file. It means the GM needs to download a CSV file with control links from Master Panel and upload it to the foundry.

Thanks to this method, SyrinControl doesn’t need a CORS proxy. However, this is still far from an acceptable solution for an average GM.
With SuperSyrin subscription, the CSV file grows up to dozens of megabytes, making the whole sync unnecessarily slow.
What is more, this method requires further re-uploads whenever you release new content, or GM buys a new Soundset.

Therefore, I believe we need to find a way to use an API without CORS in the first place.
If you need extra details about FoundryVTT API, FoundryVTT Dev Team declared they are willing to help, as well as I am :slight_smile:

Hi @Steve and @benjamin,

I’m the project coordinator for Foundry VTT. If there is anything our team can do to help reconcile any API integration issues we’ll be glad to help out. We can arrange for a channel to communicate about Frondeus’ project in our community discord if it would be helpful; or open a joint email between all of us and the FVTT staff.

Whatever we can do to assist, please let us know.

Cheers,
Shane M. (Anathema)
Project Coordinator
Foundry VTT

1 Like

Hey @sm.anathema

Awesome! Let’s get this conversation going. I’ll chat with @Steve about what works best for him, email or Discord (I don’t really do Discord… but I could make it a thing).

We’ll jump on back here in soon. :slight_smile: :smiley:

Just tried it out. Works great. What I would love is if Syrinscape would allow my players to trigger sounds in foundry based on the fact that they are connected to a session where the GM is a SuperSyrinscape owner. That way the modules ability to create macros could be used for connected players to trigger spell sounds in the game.

1 Like

This sounds great @sm.anathema, we would be very interested in having a chat to see how we could best approach this. As @benjamin mentioned above I use Foundry myself for my online gaming and would love to find an easy way to integrate the two.

I shall send you an email and then we can start to get the ball rolling :grin:

You can work around the CORS issue if you fetch blind:

    // Syrinscape currently doesn't allow CORS, so all we can get is
    // an opaque response.  That means that we can't report if
    // Syrinscape returns a 401 Forbidden.  We can detect network errors,
    // but for now we just let them go to the console.
    log("Sending Syrinscape API request for ", event);
    await fetch(apiUrl, {
        method: 'POST',      // XXX Supposedly sometimes should be GET
        mode: 'no-cors',
        cache: 'no-cache',
        credentials: 'omit',
        redirect: 'follow',
        referrerPolicy: 'no-referrer',
    });

However, I really would like to see Syrinscape add the CORS headers to the web API, so workarounds become unnecessary!

Yes, that’s precisely what SyrinControl does with the CSV synch method:

  • It can control Syrinscape Online by sending “blind” fetch (Fire and Forget)
  • However, it cannot ask Syrinscape Online for the list of all soundsets available because it needs to read the response.

That would be super cool. I think I’d need to introduce some kind of socket proxy but it is possible.

Ah, gotcha! I’m sorry; I hadn’t read the source (and missed an above post) before I posted that, and assumed you meant that you needed the proxy for all operations. (I’m very interested, but my game starts in an hour, and I’m barely prepped! On the upside I’ve got a great soundtrack going!) As your program can cache the CSV, especially since the user can upload it to be cached, then it may not be a big deal to require a proxy.

Rather than using direct user-to-user communication, what if you communicated through Foundry? You could, for instance, create a new DocumentCollection (I think there’s a tutorial for that). The player’s client creates new Documents to post requests for sounds, and the GM’s client hooks the various _onCreateDocuments etc. to fulfill them (and then delete them once fulfilled).

There’s other places where you could set requests, such as in a journal entry. But these are difficult to manage without race conditions.

Oh yes this would rock