The server keeps a play queue per client, identified by the X-Queue-Id header. The client sends the ID it has for the selected server with every request and keeps the one in each response, which is new after a reset or a sync. The IDs are saved per server in the [queues] section of settings.cfg, so the game goes on with the same queue after a restart. HttpTransport now passes the response headers on to the client.
29 lines
1.0 KiB
GDScript
29 lines
1.0 KiB
GDScript
class_name AutoloadSnapshot
|
|
extends RefCounted
|
|
## Saves and restores the script variables of autoloads such as Settings and Playlist,
|
|
## so a test that changes global state does not leak into the next test.
|
|
|
|
var _values: Dictionary = {}
|
|
|
|
|
|
## Records the current values of every script variable on [param autoloads].
|
|
static func take(autoloads: Array[Node]) -> AutoloadSnapshot:
|
|
var snapshot: AutoloadSnapshot = AutoloadSnapshot.new()
|
|
for autoload: Node in autoloads:
|
|
var values: Dictionary = {}
|
|
for property: Dictionary in autoload.get_property_list():
|
|
if property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
|
var value: Variant = autoload.get(property.name)
|
|
values[property.name] = (value.duplicate()
|
|
if value is Array || value is Dictionary else value)
|
|
snapshot._values[autoload] = values
|
|
return snapshot
|
|
|
|
|
|
## Puts back the values recorded by [method take].
|
|
func restore() -> void:
|
|
for autoload: Node in _values:
|
|
var values: Dictionary = _values[autoload]
|
|
for property_name: String in values:
|
|
autoload.set(property_name, values[property_name])
|