From 26b7a9b16837a0ba4ea919d072465eba78913973 Mon Sep 17 00:00:00 2001 From: Ewan Lyon Date: Wed, 6 Jan 2021 21:37:45 +1100 Subject: [PATCH] Add game event messages --- src/extension/messages.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/extension/messages.ts diff --git a/src/extension/messages.ts b/src/extension/messages.ts new file mode 100644 index 0000000..9e26165 --- /dev/null +++ b/src/extension/messages.ts @@ -0,0 +1,17 @@ +import * as nodecgApiContext from './util/nodecg-api-context'; +const nodecg = nodecgApiContext.get(); + +import { CSGOOutput } from '../types/csgo-gsi'; + +// Sends messages based on game information +const gameRep = nodecg.Replicant('gameRep'); + +gameRep.on('change', (newVal, oldVal) => { + if (oldVal?.phaseCountdowns.phase !== newVal.phaseCountdowns.phase) { + nodecg.sendMessage(`newPhase:${newVal.phaseCountdowns.phase}`); + } + + if (oldVal?.bomb.state !== newVal.bomb.state) { + nodecg.sendMessage(`newBomb:${newVal.bomb.state}`); + } +});