1.1.10 • Published 4 years ago

dyna-node-channels v1.1.10

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

About

Create Channels and let the receivers to get stream data on real time.

Example

The channels service

    const channelsService = new DynaNodeChannelsService({
      disk: createRam(),
      serviceRegistration: {
        encryptionKey: 'encryptionKey',
        accessKey: 'accessKey',
        serverDynaNodeAddress: 'n/localhost/33044',
        serviceConnectionId: 'feeder-service',
      },
      onChannelRegister: async (channel, accessToken) => accessToken === '####at-registration',
      onChannelPost: async (channel, accessToken) => accessToken === '####at-post',
      onMessageQueueError: e => console.error(e),
      onServiceRegistrationFail: e => console.error(e),
    });
    await channelsService.start();

Create a broadcaster instance that will push messages to the channel

    broadcaster = new DynaNodeChannelBroadcaster({
      dynaNodeChannelServiceAddress: 'feeder-service@n/localhost/33044',
      channel: 'footballGame',
      accessToken: '####at-post',
    });

and send messages to the channel like this:

   broadcaster.send({
      command: 'football-game-score--update',
      data: { host: 2, visitor: 0 }
    })

And this is the receiver that will receive the messages

    const receiver = new DynaNodeChannelReceiver({
      dynaNodeChannelServiceAddress: 'feeder-service@n/localhost/33044',
      channel: 'footballGame',
      accessToken: '####at-registration',
      onMessage: message => {
        const {
            data: {         // here we have the data posted to the channel
                host,
                visitor,
            },
        } = message;
      }
    });
    receiver.start();
1.1.9

4 years ago

1.1.10

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.1

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago