##Preamble

###The short story

Distributed computing allows for distributed lambdas (=functions). If invoking a local function, looks like this:

```javascript
var y=f(x1,x2);

/* do something with y */

```

In that case, the same function invocation, as function doing the computation on a remote server, that is, a Remote Procedure Call (RPC) looks like that:

```javascript
ws.rpc('f',[x1,x2],function(y) {

  /* do something with y */

 });
```

_Rpc WebSocket_ allows you to make remote function calls over a websocket.

###Definitions

* *message types*: Each message is always assigned a type. This allows us to transparently route messages to different handler functions.
* *RPC*: This feature implements the ability to call functions on the server using websockets. It is an alternative to ajax and to JSON-RPC.
* *before/after send/receive events*: For the purposes of logging, encryption, and compression, we need the ability to intercept incoming and outgoing messages before they are delivered to their handler functions. Depending on the application, there may be other reasons to apply wholesale changes to each incoming or outgoing message. We could, for example, add validation logic before sending messages.

I have tested _Rpc WebSocket_ with the [engine.io](https://github.com/Automattic/engine.io) and [engine.io-client](https://github.com/Automattic/engine.io-client) transport mechanisms, but you should most likely be able to use alternative websocket implementations.

