Skip to content

snodgrass23/chatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
});

About

Node module for building chat server and clients

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published