1.0.3 • Published 8 years ago

thebombemachine v1.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

The Bombe Machine

A small Javascript utility class to allow easy connection and communication with a Secret Hitler server. It is designed to work with Kyle Coburn's secret-hitler: https://github.com/kylecoburn/secret-hitler.git

Named after Alan Turing's (with a few other contributors) invention, the Bombe, which during World War II assisted in deciphering German communications. See https://wikipedia.org/wiki/Bombe.

Installation

npm install thebombemachine --save

Usage

Instantiation

//Node.js
var BombeMachine = require("thebombemachine");
var Bombe = new BombeMachine(custom_server_URL [optional]);

//Vanilla JavaScript
var Bombe = new BombeMachine(custom_server_URL [optional]);

Set up connection

Bombe.doSetup(callback_function);

Do communications

The object must have been set up first.

Handle incoming messages

var handlerID = Bombe.onReceive(callback_function);

Handle outgoing messages

var handlerID = Bombe.onSend(callback_function);

Delete event handler (either incoming or outgoing)

Bombe.removeHandler(handlerID);

Send a message to the server

Bombe.send(message_string);

Ping the server

Bombe.ping(callback_function);

Control auto-ping (the server will close the connection if it's not pinged regularly)

Bombe.startAutoPing(interval_ms [optional], timeout_ms [optional]);
Bombe.stopAutoPing();