-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconfig.ts
More file actions
48 lines (39 loc) · 1.08 KB
/
config.ts
File metadata and controls
48 lines (39 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Global configuration for the StageLinq library.
*
* This module provides a way to configure library-wide settings
* that need to be accessible from various internal modules.
*/
export type NetworkTapDirection = 'send' | 'recv' | 'discovery';
export interface NetworkTapInfo {
direction: NetworkTapDirection;
service?: string;
address: string;
port: number;
data: Uint8Array;
}
export type NetworkTapCallback = (info: NetworkTapInfo) => void;
export interface StageLinqConfig {
/** Callback invoked for every packet sent/received. Use for debugging/logging. */
networkTap?: NetworkTapCallback;
}
const defaultConfig: StageLinqConfig = {};
let config: StageLinqConfig = { ...defaultConfig };
/**
* Get the current configuration
*/
export function getConfig(): Readonly<StageLinqConfig> {
return config;
}
/**
* Update the configuration
*/
export function setConfig(newConfig: Partial<StageLinqConfig>): void {
config = { ...config, ...newConfig };
}
/**
* Reset configuration to defaults
*/
export function resetConfig(): void {
config = { ...defaultConfig };
}