0.69.0 • Published 1 year ago

@curium.rocks/ping-pong-emitter v0.69.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ping-pong-emitter

Quality Gate Status Coverage Security Rating

Purpose

The purpose of this class is to create an emitter that will periodically emit a ping message expecting a pong response. Likewise, it can be pinged, and it will send a pong back. This can be used as a test class for emitter transceivers, as well as a general comm link check akin to a keep alive.

How to use

Install

npm install --save @curium.rocks/ping-pong-emitter

API Documentation

You can view the API documentation here.

Examples

import {isPingPongMessage, PingPongEmitter, PingPongMessage, PingPongMessageType} from '@curium.rocks/ping-pong-emitter';
import {IDataEvent} from '@curium.rocks/data-emitter-base';

const emitter = new PingPongEmitter('unique-id', 'usefull-name', 'lengthy description', 1000);
emitter.startPolling();
const disposable = emitter.onData(async (evt) => {
    if(!isPingPongMessage(evt.data)) console.log('What... not a ping pong message!');
    if((evt.data as PingPongMessage).type == PingPongMessageType.PING) {
        console.log("I've been pinged!, I better send a pong");
        await emitter.sendCommand({
            actionId: 'unique-action-id',
            payload: {
                type: PingPongMessageType.PONG
            }
        });
        console.log("Ponged back!");
    }
});

// check on the state 

const state = await emitter.probeStatus();

if (state.bit) {
    console.log('BIT flag on indicates BIT failure, not getting pongs!');
}

// want to change the ping interval

const cmdResult = await emitter.sendCommand({
    actionId: 'unique-id',
    name: 'new-name',
    id: 'new-emitter-id',
    description: 'new-emitter-description',
    interval: 5000 //interval in ms
});

// check cmd result

if(!cmdResult.success) {
    console.log(`Error while executing cmd: ${cmdResult.actionId}, reason: ${cmdResult.failureReason}`);
}

// when done cleanup
emitter.dispose();
0.62.0

1 year ago

0.67.0

1 year ago

0.63.0

1 year ago

0.68.0

1 year ago

0.64.0

1 year ago

0.69.0

1 year ago

0.65.0

1 year ago

0.66.0

1 year ago

0.59.0

2 years ago

0.55.0

2 years ago

0.51.0

2 years ago

0.48.0

2 years ago

0.56.0

2 years ago

0.52.0

2 years ago

0.49.0

2 years ago

0.60.0

2 years ago

0.57.0

2 years ago

0.53.0

2 years ago

0.46.0

2 years ago

0.61.0

2 years ago

0.58.0

2 years ago

0.54.0

2 years ago

0.50.0

2 years ago

0.47.0

2 years ago

0.43.0

2 years ago

0.20.0

2 years ago

0.41.0

2 years ago

0.19.0

2 years ago

0.38.0

2 years ago

0.36.0

2 years ago

0.34.0

2 years ago

0.11.0

2 years ago

0.13.0

2 years ago

0.15.0

2 years ago

0.17.0

2 years ago

0.32.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.27.0

2 years ago

0.25.0

2 years ago

0.44.0

2 years ago

0.23.0

2 years ago

0.9.0

2 years ago

0.5.0

2 years ago

0.7.0

2 years ago

0.42.0

2 years ago

0.21.0

2 years ago

0.40.0

2 years ago

0.39.0

2 years ago

0.37.0

2 years ago

0.35.0

2 years ago

0.33.0

2 years ago

0.12.0

2 years ago

0.14.0

2 years ago

0.16.0

2 years ago

0.18.0

2 years ago

0.10.0

2 years ago

0.31.0

2 years ago

0.28.0

2 years ago

0.26.0

2 years ago

0.24.0

2 years ago

0.45.0

2 years ago

0.22.0

2 years ago

0.8.0

2 years ago

0.4.0

2 years ago

0.6.0

2 years ago

0.1.1-27

2 years ago

0.1.1-28

2 years ago

0.1.1-29

2 years ago

0.1.1-25

2 years ago

0.1.1-26

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.1-34

2 years ago

0.1.1-35

2 years ago

0.1.1-36

2 years ago

0.1.1-37

2 years ago

0.1.1-30

2 years ago

0.1.1-31

2 years ago

0.1.1-32

2 years ago

0.1.1-33

2 years ago

0.1.1-23

2 years ago

0.1.1-24

2 years ago

0.1.1-22

2 years ago

0.1.1-21

2 years ago

0.1.1-16

2 years ago

0.1.1-17

2 years ago

0.1.1-18

2 years ago

0.1.1-19

2 years ago

0.1.1-20

2 years ago

0.1.1-14

3 years ago

0.1.1-15

3 years ago

0.1.1-13

3 years ago

0.1.1-12

3 years ago

0.1.1-11

3 years ago

0.1.1-10

3 years ago

0.1.1-9

3 years ago

0.1.1-6

3 years ago

0.1.1-8

3 years ago

0.1.1-7

3 years ago

0.1.1-5

3 years ago

0.1.1-4

3 years ago

0.1.1-3

3 years ago

0.1.1-2

3 years ago

0.1.1-1

3 years ago

0.1.1-0

3 years ago