Skip to content

[RFC] Shared sandboxes #1

@trezy

Description

@trezy
Authors @trezy
To be reviewed by 06 October, 2020

Need

Developers using fdgt to develop their Twitch applications (bots, overlays, extensions, etc) are often confused by the way that fdgt sandboxes connections. A common refrain is, "I've connected my bot to fdgt... now how do I connect with a chat client to send commands?" This confusion is caused because every connection is isolated inside of its own sandbox. This creates two important conditions:

  1. The benefit is that commands sent to one connection won't affect other connections (e.g., When Bob sends a command, Sally won't see the effects of that command because their connections are completely isolated.
  2. The downside is that developers can't have multiple clients interact with each other. A command scenario would be a streamer creating both a bot and an overlay. Events triggered by the chat connection should trigger actions in both the overlay and the bot simultaneously. This is currently impossible because of the isolated sandbox.

To clear up this confusion and introduce the functionality that developers expect, we need to allow multiple clients to share a sandbox.

Approach

To introduce shared sandboxes, we'll need a few new pieces of infrastructure to be implemented. These span both the fdgt API and website.

  1. Accounts/Logins
    To create and manage shared sandboxes, users will need to create a fdgt account (not necessarily custom accounts, could also be login with a third party account like Google, Twitter, Github, or Twitch). This allows us to track who is using shared sandboxes in case we need to lock down accounts that are abusing the system.
  2. Sandbox Storage
    Connections to fdgt will remain isolated in code, but they will be connected by a backend that shares data to all connections that are using the same sandbox.
  3. Programmatic Sandbox API
    We'll want to create a new API endpoint that allows users to create new sandboxes programmatically. This will be helpful for automated tests to spin create a new sandbox for a test instance, then delete that sandbox after the tests have finished.

Benefits

Introducing shared sandboxes will allow the testing of multiple different scenarios...

Simple manual testing and interaction

When testing a bot against the actual Twitch API, developers can connect their application and a chat client and affect the application by sending messages from their client. Currently, there is no way for multiple clients to interact via the fdgt chat API. This prevents developers from using simple manual testing to verify their connections to fdgt before writing full-fledged tests.

Automated testing

Currently, testing an application against fdgt requires commands to be sent on the same connection as the application being tested. This is problematic if the tests are watching that connection to verify message sending/receipt, or if the framework connecting the application to fdgt needs to be monkey patched to allow the connection to be shared.

Interacting clients

It's not difficult to imagine a developer creating a bot and an overlay and making them both react to the same commands in chat. A contrived example might be a bot that updates a counter field in a database when the !count command is called, while that same command causes the overlay to update an on-screen counter.

Alternatives

Remove sandboxes

This is just a straight up bad idea, but here's the pitch: instead of creating personalized sandboxes, we would remove sandboxes entirely and encourage users to create unique rooms for their test suites.

This is the worst of ideas because it virtually encourages abuse. One user could, in theory, create an application that brute force connects to channels, then sends random messages. This would interfere anytime the application connects to a channel that is currently in use by a test suite. The application could also capture any data sent on the channel, potentially exposing sensitive data that was expected to be sent in secret.

Acknowledgements

Big thanks to @callowcreation, @sadmoody, and @Layla-P for helping flesh out the need for this upgrade

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions