How to use the @casual-simulation/aux-common.action function in @casual-simulation/aux-common

To help you get started, we’ve selected a few @casual-simulation/aux-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-vm-node / modules / AdminModule.spec.ts View on Github external
channel.remoteEvents.subscribe(e => events.push(...e));

                await channel.sendEvents([
                    {
                        type: 'device',
                        device: device,
                        event: echo('test'),
                    },
                ]);

                // Wait for the async operations to finish
                await Promise.resolve();
                await Promise.resolve();

                expect(events).toEqual([
                    remote(action('test'), {
                        sessionId: device.claims[SESSION_ID_CLAIM],
                    }),
                ]);
            });
        });
github casual-simulation / aux / src / aux-server / server / modules / SetupChannelModule2.ts View on Github external
try {
                    await simulation.init();

                    if (event.botOrMod) {
                        console.log(`[SetupChannelModule2] Creating new bot`);
                        const botId = await simulation.helper.createBot(
                            undefined,
                            isBot(event.botOrMod)
                                ? event.botOrMod.tags
                                : event.botOrMod
                        );
                        console.log(
                            `[SetupChannelModule2] Created bot ${botId}`
                        );
                        await simulation.helper.transaction(
                            action(
                                CREATE_ACTION_NAME,
                                [botId],
                                simulation.helper.userId
                            )
                        );
                    }
                } finally {
                    simulation.unsubscribe();
                }
            }
        } catch (err) {
            console.error('[SetupChannelModule2]', err);
        }
    }
}
github casual-simulation / aux / src / aux-vm / vm / AuxHelper.spec.ts View on Github external
it('should run action events', async () => {
            await helper.createFile('test', {
                'action()': 'setTag(this, "#hit", true)',
            });

            await helper.transaction(action('action', ['test'], 'user'));

            expect(helper.filesState['test'].tags.hit).toBe(true);
        });
github casual-simulation / aux / src / aux-server / server / modules / SetupChannelModule.ts View on Github external
);
                const channel = await this._channelManager.loadChannel(
                    newChannelInfo
                );

                if (event.botOrMod) {
                    console.log(`[SetupChannelModule] Creating new bot`);
                    const botId = await channel.channel.helper.createBot(
                        undefined,
                        isBot(event.botOrMod)
                            ? event.botOrMod.tags
                            : event.botOrMod
                    );
                    console.log(`[SetupChannelModule] Created bot ${botId}`);
                    await channel.channel.helper.transaction(
                        action(
                            CREATE_ACTION_NAME,
                            [botId],
                            channel.channel.helper.userId
                        )
                    );
                }
            }
        } catch (err) {
            console.error('[SetupChannelModule]', err);
        }
    }
}
github casual-simulation / aux / src / aux-server / server / modules / FilesModule.ts View on Github external
private async _sendCallback(
        event: SaveFileAction | LoadFileAction,
        channel: NodeAuxChannel,
        arg: any
    ) {
        if (event.options.callbackShout) {
            await channel.helper.transaction(
                action(
                    event.options.callbackShout,
                    null,
                    channel.helper.userId,
                    arg
                )
            );
        }
    }