evantahler/actionHero — pull request #294 by evantahler (2014-01-13 01:44:25+00:00)
Title: websocket updates

A collection of websocket updates:

#### Websocket clients can now request files
- `client.file('path/to/file', callback)`
- data in the callback is of the form:

``` javascript
{
content: "

ActionHero

\nI am a flat file being served to you via the API from ./public/simple.html
",
context: "response",
error: null,
length: 101,
messageCount: 3,
mime: "text/html"
}
```

### http actions
- The "actionHeroClient" client-side library can now be used to make http actions when not connected as a websocket (and websocket clients will fall back to http actions when disconnected)

``` javascript
var client = new actionHeroClient();
client.action('cacheTest', {key: 'k', value: 'v'}, function(err, data){
// do stuff
});
```

### client events
- The client has been modified to emit events (like on the server side)
- This replaces the `client.events` hash. Do not use it any more.
- Logging has been removed from the client in favor of events
- You can use `client.on('message')` to capture every message from the server

```javascript
client = new actionHeroClient;

client.on('connected', function(){ console.log('connected!') })
client.on('disconnected', function(){ console.log('disconnected :(') })

client.on('message', function(message){ console.log(message) })

client.on('alert', function(message){ alert(message) })
client.on('api', function(message){ alert(message) })

client.on('welcome', function(message){ appendMessage(message); })
client.on('say', function(message){ appendMessage(message); })
```

### Misc
- The javascript files have been renamed to `actionHeroClient.js`
- ``
-