Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update readme to sound like a person without intellectual difficultie…

…s wrote it.
  • Loading branch information...
commit 789357841a7252fb44ea44c08f04ee4b8c72085b 1 parent f47ab73
@timoxley authored
Showing with 37 additions and 41 deletions.
  1. +37 −41
@@ -10,27 +10,21 @@ so I wrapped them up in an 'easier' interface.
### Features and Differences from DNode
-* eNode makes a sharp distinction between Clients and Servers
-* **Automatic buffering of requests and reconnections** on lost servers as provided
- by upnode is configured by default between Servers and Clients
-* All 'connection' handling code is done in the 'connect' event, and
- unlike Dnode, the Servers/Clients don't return fire any callbacks/events
- until they have recieved the remote's API
-* **Each API call gets passed remote API & connection properties** in a `meta` property
- (as the last argument). This means you don't necessarily need to
- define your API inside the scope of connection handlers to get access to
- connection/remote objects.
-* **Servers automatically keep a list of connected Clients.**.
- This is accessible via the server's `connections` Array.
-* **The `shutdown` function on both Servers and Clients simplifies
- closing down a connection**.
- Using DNode this was a multistep, strange danceto know when a connection was
+* eNode makes a sharp distinction between Clients and Servers.
+* **Automatic buffering of requests and reconnections**. Upnode is configured
+ automatically between Servers and Clients.
+* Servers & Clients don't fire callbacks/events until they recieve the remote's API.
+* Unlike Dnode, you don't necessarily need to define the remote API inside the lexical
+ scope of the connection handler to gain access to the remote api and connection.
+ **All API calls get passed the remote API & connection**, as the final argument of each api call.
+* **Servers automatically keep a list of connected Clients** accessible
+ as `server.connections`.
+* **The `shutdown` function on Servers and Clients simplifies
+ closing connections**. Using DNode, it is a multi-step dance to know when a connection is
actually closed.
-* To get around a 'bug' in DNode on 0.6.x, eNode finds `Error` objects in the data you're returning
- in your remote callback, and uses `err.toString()` to convert the Error into a String
- format like: 'Error: Some error occurred'.
- If you want to transmit more information about Errors, you can provide a different
- serialisation method by simply overriding `serializeError` on eNode Clients & Servers.
+* DNode on 0.6.x doesn\'t serialize Error objects very usefully (it serializes them as `{}`).
+ eNode finds `Error` objects in your remote callback data, serializing them to a human readable format.
+ You can override the `serializeError` method to expose more or less information.
## Usage
@@ -48,7 +42,7 @@ As with DNode, properties on prototypes and return values are ignored.
var api = {
sendInfo: function(info, callback) {
// do something with info
- callback(null, {data: 'got some info: ' + info}) // stupid api
+ callback(null, {data: 'Server got some info: ' + info}) // stupid api
@@ -71,36 +65,38 @@ var client = enode.Client().connect(3000)
-// Execute remote method 'getSomeData' from Server
-client.once('ready', function(serverAPI, connection) {
- var info = 'bovine'
- serverAPI.sendInfo(info, function(err, returnedData) {
- console.log( // 'got some info: bovine'
+// Execute remote method 'sendInfo' on Server
+client.once('ready', function(server, connection) {
+ // send info to the server via the api the server exposed
+ server.sendInfo('Hello from client.', function(err, returnedData) {
+ console.log(
+ // Output: 'Server got some info: Hello from client.'
-### Creating a Client with an API and connecting to a Server
+### Creating a Client that exposes an API and connecting to a Server
var client
+// Create a client api
var api = {
shutdown_client: function(callback) {
-// Clients can have API's too
client = enode.Client(api).connect(3000)
-### Calling a Client API from a Server
+### Calling the Client's methods from a Server
-// 'connect' event is fired every time a Client connects
+// 'connect' event is fired each time a Client connects
server.on('connect', function(clientAPI, connection) {
// Call remote Client's `shutdown_client` method
clientAPI.shutdown_client(function(err) {
@@ -112,7 +108,7 @@ server.on('connect', function(clientAPI, connection) {
-### Shutting down a Server/Client
+### Shutting down Clients & Servers
@@ -120,36 +116,36 @@ server.shutdown(function() {
console.log('Callback: the server shutdown')
+client.shutdown(function() {
+ console.log('Callback: the client shutdown')
-// The 'shutdown' event should execute around same time as shutdown() callback is run
+// 'shutdown' events will also fire
server.on('shutdown', function() {
console.log('Event: the server shutdown')
-client.shutdown(function() {
- console.log('Callback: the client shutdown')
client.on('shutdown', function() {
console.log('Event: the client shutdown')
-### Returning Errors
+### Passing Errors
-// Note APIs can be defined inline,
-// no need to create a new variable.
+// Create a Server with a `makeError` method
var server = new enode.Server({
makeError: function(callback) {
+ // send an error back to the client
callback(new Error('oops'))
var client = new enode.Client().connect(3000, function(serverAPI) {
- // this callback should receive an `Error` cast to a `String`
+ // this callback should receive the `Error` as a `String`
serverAPI.makeError(function(err) {
console.log(typeof err) // 'string'
console.log(err) // Error: oops
@@ -209,7 +205,7 @@ client.on('ready', function(remote) {
-* Implement middleware
+* Implement/expose middleware
* More usage examples
## Contributors
Please sign in to comment.
Something went wrong with that request. Please try again.