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
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.
In addition to the
net functionality, the
In addition to the options available to
Net.Server, an asbs Socket accepts
var mySock =host: 'localhost' // from Net.Socketport: 2010 // from Net.Socketbool: true // Cast all known boolean fields into boolean valuesenum: true // Cast all known enumerated field into enums;
Some developers prefer integer values to booleans (
1 instead of
false), and some prefer integer values to enums (e.g.
3 instead of
mine). Both options default to
true for maximum prettifycation.
Each time a known game packet is received (and parsed), this event is emmited. The callback should expect two parameters:
packetName is self-explaining.
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(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.
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.
node-artemis-lib.Socket is a subclass of EventEmitter and, as such, instead of
throwing errors it emits
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.
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.
Works exactly as a
net.Server, but the spawned sockets will behave as
asbs-lib.Socket instead of plain
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.
Beerware license, see LICENSE file.