@casual-simulation/aux-vm-client
    TypeScript icon, indicating that this package has built-in type declarations

    3.1.12-alpha.3578187535 • Public • Published

    AUX VM Client

    npm (scoped)

    A set of utilities required to run an AUX as a client.

    Installation

    npm install @casual-simulation/aux-vm-client
    

    Usage

    Create a custom channel implementation

    import { RemoteAuxChannel } from '@casual-simulation/aux-vm-client';
    import { AuxUser, AuxConfig } from '@casual-simulation/aux-vm';
    
    export class MyCustomChannel extends RemoteAuxChannel {
    
        constructor(defaultHost: string, user: AuxUser, config: AuxConfig) {
            super(defaultHost, user, config, {});
        }
    
        // Override the _handleServerEvents function
        // to handle events sent from a remote device.
        protected async _handleServerEvents(events: DeviceAction[]) {
            await super._handleServerEvents(events);
            let filtered = events.filter(
                e => e.device.roles.indexOf(SERVER_ROLE) >= 0
            );
            let mapped = <BotAction[]>filtered.map(e => e.event);
            if (filtered.length > 0) {
                await this.sendEvents(mapped);
            }
        }
    }

    Keywords

    Install

    npm i @casual-simulation/aux-vm-client

    DownloadsWeekly Downloads

    414

    Version

    3.1.12-alpha.3578187535

    License

    MIT

    Unpacked Size

    32.3 kB

    Total Files

    34

    Last publish

    Collaborators

    • kallyngowdyyeti
    • casualsimulation