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

sysbot-net-api

v2.0.12

Published

A very simple and lightweight package that allows to subscribe to events coming from SysBot.ACNHOrders and make HTTP-like requests to it, via the bot's SocketAPIServer.

Downloads

32

Readme

SysBot.NET TypeScript API

Code Size npm Total Downloads GitHub Open Issues

A very simple and lightweight TypeScript package that allows to subscribe to events coming from SysBot.ACNHOrders and make HTTP-like requests to it, via SysBot's SocketAPIServer.

Installation

npm install -S sysbot-net-api

Usage

import { SocketAPIClient, SocketAPIRequest, SocketAPIMessage } from 'sysbot-net-api';

// Start the client
const _connected: boolean = await SocketAPIClient.start('127.0.0.1', 9001, {
    reconnect: true,
    reconnectMaxRetries: 10,
    reconnectTimeout: 4000,
    connectTimeout: 8000,
    requestTimeout: 4000
});

SocketAPIClient.subscribe(message => {
    console.log('Event received!', message); // Instance of `SocketAPIMessage`
});

// Take a look at request format below!
const request: SocketAPIRequest<{ myNum: number }> = new SocketAPIRequest<{ myNum: number }>('addOne', JSON.stringify({
    myArg: 2
}));

const response: SocketAPIMessage<number> = await SocketAPIClient.sendRequest<number>(request, 2000);
// response: 3

Request format

  • id: a unique identifier for the request. This can be either manually or automatically assigned: by accessing the id property of your SocketAPIRequest instance or by passing it to the constructor. If none is passed to the constructor, a random UUID is generated and assigned to it.
  • endpoint: the endpoint name of the remote bot method to call. Case-sensitive.
  • args: a JSON-formatted object string that will be passed to the endpoint. If a non-JSON valid string is given, it will be first JSON encoded.

Response format - SocketAPIMessage<T>

  • status: either "okay" or "error".
  • id: the ID that was provided by the request.
  • _type: the type of response, can be either event or response; used internally.
  • value: contains the response body, the actual value of the response; undefined if the remote endpoint returns Void.
  • error: if the remote endpoint catches or throws an error, this would contain the error message.

Heartbeats

The remote host periodically sends special packets to check against half-open connections and eventually handle and dispose the client's socket.

These packets contain a message that starts with hb, followed by a space \s and a UUID string that uniquely identifies the sent heartbeat. The client must reply to the remote host with exactly the same message it received.

Reconnection

By passing a SocketAPIOptions object to the .start() method as third parameter, it is possible for the client to automatically reconnect to the initially designated host.

Other options can be specified too:

{
    reconnect: true,            // Whether to enable auto-reconnect logic or not.
    reconnectMaxRetries: 10,    // The maximum number of reconnect retries.
    reconnectTimeout: 4000,     // The time that between a reconnection attempt and the next.
    connectTimeout: 8000,       // The time it takes for the first connection (.start()) attempt to be considered timed out.
    requestTimeout: 4000        // The time it takes for a request to the host to be considered timed out.
}

debug

This package uses the npm debug package to output useful debug info to console. Subscribe to the debug asyncSocket and socketAPIClient topics to show debug info to console.

License

GNU General Public License, see LICENSE for details. Pull requests are more than welcome, help & suggestions are very much appreciated. :)