Multi User Support - JimAnkrom/sway GitHub Wiki
To support multiple users vying for control of multiple controllable assets, Sway uses a concept called Channels.
Think of each channel as if it were a single player station on a multi-user arcade game. That player's station - a channel - may have joysticks, buttons, and other controllers similar to other player stations, but those controls distinctly control a specific character in the game. Now envision the line - a queue - forming behind a specific station as players want to play that particular character. Sway makes this control station concept a reality.
In Sway, Channels are configurable control data queues. Each channel is made up of a configurable mapping of input data source and output data destination (OSC address). This concept allows Sway to divide users into queues for specific tasks. Each task may have similar controls than other tasks, or it may not. Each control within the channel is configurable to an output destination to control.
To enable efficient queuing of many users waiting to interact with your installation, Sway has configurable load balancers. These load balancers take a new user entering the system and find the right queue for them based on load. To best meet your installation's interactivity needs, Sway supports a few load management algorithms including:
- round robin - users enter channels in the order they appear in the configuration
- shuffled deck - shuffle the order of channels once, then load is round robin into that list.
- random - user is entered into a random channel
- weighted - user is added to the channel with the highest percentage of available seats.
In addition, Sway users may be request to be reassigned to a specific channel, through creating UIs that allow them to request a channel.
Developers can also add their own load balancer by assigning a function to sway.channelControl.LoadBalancer.
- sway.users has a 'expire' method which assesses each user and marks them expired, and then raises onExpireUser. When it is complete it then raises onExpireUserBatch.
- sway.channels has a compact channel method, which finds all users marked expired.
- Overflow Queues - Each channel can have a queue size/capacity limit. This enables Sway's load balancers to move users into secondary overflow queues. To entertain an overflow crowd, channels may be configured to support multiple simultaneous users. Some installations may not care if many users are clicking a button at once, for example.
- Queue Workflows / Channel Chaining / Promotion - Support the ability to chain channels so users may be promoted based on certain conditions. This allows a user to 'level up', or could be used to better manage load. As an active user reaches certain states in the UI, they request entry into a new channel.
Channels are configured in sway.channels.json.