Node module for building chat server and clients
JavaScript Makefile
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
chatter_client
examples
lib
.gitignore
Makefile
Procfile
index.js
package.json
readme.md

readme.md

Chatter

An npm module for creating chat servers and clients.

Check out the examples directory for CLI server and client apps.

Install with npm

NOTE: This has been removed from npm so another developer could use the name. Download and install manually as needed.

Node Server

var chatter = require('chatter');
var options = {
  port: process.env.PORT || 8000
}
var chatter_server = new chatter.server(options);

Node Client

var chatter = require('chatter');
var chatter_client = new chatter.client("http://chatterjs.herokuapp.com");

// get last 10 messages in transcript
chatter_client.getRecentHistory();

// start listening for new messages
chatter_client.on('message', function(message) {
  console.log(message);
});

// send new message with body and user
chatter_client.send('Hello World', 'Jim');

Front-End Client

requires "JQuery-like" library for ajax calls. Primary testing done using zepto.js

<script src="http://chatterjs.herokuapp.com/chatter/chatter.js"></script>
// first argument is host server, second is callback for new messages
// last argument is optional for polling interval
chatter.connect('http://chatterjs.herokuapp.com', function(data) {
  console.log("handling new message: ", data);
}, 500);

// method to get last 10 messages in room
chatter.getRecentHistory();

// has optional callback to get created message returned
chatter.send("Hello World!", "Client", function(response) {
  console.log("new message", response);
});