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

asbs-lib

v0.1.1

Published

Low-level interface library to Artemis SBS game servers/clients

Downloads

5

Readme

node-asbs-lib

The bastard child of artemis-glitter and node-artemis, now in reusable library form.

Heavy work in progress!! Some packets are not parsed yet, interface is not stable, lotsa stuff to do.

The goal is to abstract the low-level details of the Artemis Space Bridge Simulator protocol, exposing a subclass of net.Socket, called artemisSocket (and net.Server, called artemisServer).

Ideally, splitting the network library will allow programs and scripts to switch the version of node-asbs-lib for newer versions of ArtemisSBS and still work seamlessly even when the protocol changes.

This does not implement a world model, socket reconnection, packet forwarding, or game logic. That is left for the code using this library.

API

asbs-lib.Socket

In addition to the net functionality, the node-artemis-lib.Sockets implement:

constructor(options)

In addition to the options available to Net.Server, an asbs Socket accepts enum and bool:

var mySock = new asbs.Socket({
	host: 'localhost'	// from Net.Socket
	port: 2010,	// from Net.Socket
	bool: true,	// Cast all known boolean fields into boolean values
	enum: true	// Cast all known enumerated field into enums
});

Some developers prefer integer values to booleans (0 or 1 instead of true and false), and some prefer integer values to enums (e.g. 0 to 3 instead of homing, nuke, emp and mine). Both options default to true for maximum prettifycation.

event: packet

Each time a known game packet is received (and parsed), this event is emmited. The callback should expect two parameters: packetName and packetData.

packetName is self-explaining. packetData is a plain javascript object, and its structure mimics the definition in the packet-defs.js file. packetDatas may include arrays and plain objects inside, as per their definitions.

New developers are encouraged to run some of the examples to see how the event payloads look like.

send()

send(str packetName, object packetData, bool fromServer)

Kinda the inverse operation of the packet event. Given a packet name and payload, will pack it in a binary structure and send it down the wire.

Set fromServer to false if you are using artemisSocket to connect to a game server; this should be true only if you're implementing game server-like or proxy-like functionality.

event: error

An node-artemis-lib.Socket is a subclass of EventEmitter and, as such, instead of throwing errors it emits error events.

Besides the errors from net.Socket, problems when parsing Artemis SBS packets will emit an error event with a ParseError as a parameter. As with net.Socket, this event will cause the socket to close.

event: unparsed

Similar to the error event, but used for recoverable errors that shouldn't cause the socket to close, like a packet length mismatch, body parse error, etc. A ParseError will be provided as a parameter.

asbs-lib.Server

Works exactly as a net.Server, but the spawned sockets will behave as asbs-lib.Socket instead of plain net.Sockets.

Examples

There are a few example scripts in the examples/ directory. They are some of the simplest things that can be performed with the library, pretty small and commented.

Note that these examples do NOT handle socket reconnections and will fail if you don't have a game running in localhost.

Legalese

Beerware license, see LICENSE file.

Kudos to Artemis Spaceship Bridge Simulator, ArtClientLib packet protocol and node-artemis.