@mixer/interactive-node
Version:
A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol
57 lines (56 loc) • 2.19 kB
TypeScript
/// <reference types="node" />
import { EventEmitter } from 'events';
import { IClient } from '../../IClient';
import { IParticipant } from '../interfaces';
import { IControl, IControlData, IControlUpdate, IGridPlacement } from '../interfaces/controls/IControl';
import { IInput, IInputEvent } from '../interfaces/controls/IInput';
import { IMeta } from '../interfaces/controls/IMeta';
import { Scene } from '../Scene';
/**
* Control is used a base class for all other controls within an interactive session.
* It contains shared logic which all types of controls can utilize.
*/
export declare class Control<T extends IControlData> extends EventEmitter implements IControl {
controlID: string;
kind: string;
disabled: boolean;
position: IGridPlacement[];
/** @deprecated etags are no longer used, you can always omit/ignore this */
etag: string;
meta: IMeta;
protected scene: Scene;
client: IClient;
/**
* Sets the scene this control belongs to.
*/
setScene(scene: Scene): void;
/**
* Sets the client instance this control can use to execute methods.
*/
setClient(client: IClient): void;
constructor(control: T);
giveInput?(input: IInput): Promise<void>;
/**
* Called by client when it receives an input event for this control from the server.
*/
receiveInput<T extends IInput>(inputEvent: IInputEvent<T>, participant: IParticipant): void;
protected sendInput<K extends IInput>(input: K): Promise<void>;
/**
* Disables this control, preventing participant interaction.
*/
disable(): Promise<void>;
/**
* Enables this control, allowing participant interaction.
*/
enable(): Promise<void>;
protected updateAttribute<K extends keyof T>(attribute: K, value: T[K]): Promise<void>;
/**
* Merges in values from the server in response to an update operation from the server.
*/
onUpdate(controlData: IControlData): void;
/**
* Update this control on the server.
*/
update<T2 extends IControlUpdate>(controlUpdate: T2): Promise<void>;
destroy(): void;
}