npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ablyd-client

v1.1.1

Published

A client to simplify interacting with an AblyD instance

Downloads

1

Readme

ablyd-client

npm version

A JavaScript library for interacting with AblyD, a program which allows for simple creation and control of command-line interace processes via Ably Realtime, a realtime data delivery platform.

Installation

Node.js

npm install ablyd-client --save

and require as:

var AblyDClient = require('ablyd-client');

Introduction

All examples assume a client has been created as follows:

// basic auth with an API key
var ablydClient = new AblyDClient("API_KEY");

// using a Client Options object, see https://www.ably.com/documentation/realtime/usage#client-options
// which must contain at least one auth option, i.e. at least
// one of: key, token, tokenDetails, authUrl, or authCallback
var ablydClient = new AblyDClient(clientOptionsObject);

Starting a Process

Assuming you have an AblyD instance running on the same app as the auth details provided, you can start a process on it with:

ablydClient.startNewProcess(serverID, args, function(err, ablydProcess) {
    if (err) console.log(err);
});

An error is returned if no active AblyD instances exist which are listening for commands.

Alternatively if there's an already active process you'd like to interact with, you can get it with:

ablydClient.getProcess("process:namespace", function(ablydProcess) {
    ...
});

Checking currently active processes

You can get a list of active processes with:

// Get all active processes
ablydClient.getProcesses(function(ablydProcesses) {
    ablydProcesses // [ '382448', '372849', '232498' ]
});

You can also get the channel names for processes, which is useful for using getProcess:

ablydClient.getProcessChannels(function(processChannels) {
    processChannels // [ 'ablyd:c41svahe008bcgv37el0:48506', 'ablyd:c41svahe008bcgv37el0:48518' ]
});

Subscribing to a process

You can subscribe to the output of a process with:

err = ablydClient.subscribe(function (message) {
  message.name; // 'greeting'
  message.data; // 'Hello World from process!'
});

Publishing to a channel

// Publish a single message with name and data
ablydProcess.publish('greeting', 'Hello World from client to process!');

// Optionally, you can use a callback to be notified of success or failure
ablyDProcess.publish('greeting', 'Hello World from client to process!', function(err) {
  if(err) {
    console.log('publish failed with error ' + err);
  } else {
    console.log('publish succeeded');
  }
});

Listening to server changes

You can see what the state of currently active AblyD servers are with:

ablydClient.getServerStatuses((err, serverStatuses) {
    serverStatuses[0] // {
                      //   action: 'present',
                      //   id: 'TV8-xpttP-:4:0',
                      //   timestamp: 1627643396934,
                      //   clientId: 'c41trvpe008d13aqm8tg',
                      //   connectionId: 'TV8-xpttP-',
                      //   data: {
                      //     ServerID: 'c41trvpe008d13aqm8tg',
                      //     Namespace: 'ablyd',
                      //     MaxProcesses: 20,
                      //     Processes: { '53392': 'Running' }
                      //   },
                      //   encoding: null,
                      //   size: undefined
                      // }
});

You can listen for whenever servers start with:

ablydClient.subscribeToServerStarted((serverStartedMessage) => {

});

You can listen for whenever servers stops with:

ablydClient.subscribeToServerStopped((serverStartedMessage) => {

});

You can listen for whenever server's state changes (such as a new process starting on it):

ablydClient.subscribeToServerChanged((serverStartedMessage) => {

});

Support, feedback and troubleshooting

Please view or report issues to the Github issues.