• Stars
    star
    188
  • Rank 204,799 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 14 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chat server built on node

NodeChat

NodeChat is a simple, scalable web-based chat server built on Node.js.

Server

Creating a chat server is super simple.

// create a server at http://localhost:8001
var chat = require("lib/server");
var chatServer = chat.createServer();
chatServer.listen(8001);

Once you've created a server, you can add channels.

// create a channel at http://localhost:8001/chat
var channel = chatServer.addChannel({ basePath: "/chat" });

Channels have three options:

  • basePath (required) - the URL to use for the channel
  • messageBacklog (default 200) - how many message to keep in memory
  • sessionTimeout (default 60) - how many seconds to wait before killing inactive sessions

Client

NodeChat comes with a client library built on jQuery to make it easy to connect to a NodeChat server.

// connect to a channel
var channel = nodeChat.connect("http://localhost:8001/chat");

// join the channel
channel.join("my-nick");

// send a message to the channel
channel.send("hello");

// leave the channel
channel.part();

Events

The server and client both emit events on the channel objects.

  • join - emitted when someone joins the channel.
  • msg - emitted when someone sends a message to the channel.
  • part - emitted when someone leaves the channel.

Each event receives an object with the following properties:

  • id - unique id for the event (unique per channel).
  • nick - the nick of the user who performed the action.
  • type - the type of action (will be same as the event type).
  • text - text associated with the action.
  • timestamp - when the action occurred.

In addition, the client emits a connectionerror event if the connection to the server is lost.

Installation & Demo

To install:

git clone http://github.com/scottgonzalez/node-chat.git

To run the demo:

./node-chat/demo/chat.js

Then open http://localhost:8001 in a browser.

License

Copyright 2013 Scott González. Released under the terms of the MIT license.

More Repositories

1

node-wordpress

node.js client for WordPress
JavaScript
516
star
2

node-browserstack

node.js client for BrowserStack
JavaScript
215
star
3

pretty-diff

colorized HTML diffs
JavaScript
211
star
4

jquery-ui-extensions

extensions to jQuery UI
JavaScript
170
star
5

grunt-wordpress

Grunt plugin for publishing content to WordPress
PHP
128
star
6

figlet-js

JavaScript parser for FIGlet fonts
JavaScript
118
star
7

recursive-blame

Recursive blame for Git
JavaScript
69
star
8

gilded-wordpress

Easily synchronize content between the file system and WordPress
JavaScript
53
star
9

sane-email-validation

Sanely validate email addresses, based on HTML5's definition of email addresses
JavaScript
37
star
10

node-git-tools

Tools for parsing data out of git repositories.
JavaScript
32
star
11

widget-factory-docs

32
star
12

node-github-notifier

Listen for GitHub updates using an EventEmitter.
JavaScript
18
star
13

grunt-git-authors

JavaScript
16
star
14

jquery-ui-1.8-widget-factory

Code sample showing the main changes between the widget factory in jQuery UI 1.7.2 and 1.8
JavaScript
12
star
15

frontend-masters-week-3

JavaScript
10
star
16

github-request

Low level helper for working with the GitHub API.
JavaScript
9
star
17

node-ircd

Node IRC
JavaScript
8
star
18

better-diff

The diff tool of the future
7
star
19

webchat

a full featured web chat built on node-chat
JavaScript
6
star
20

debt

DEBT: Exceptional Bug Tracking
JavaScript
5
star
21

blue-owl-core

Technical Official device integration for OWLCMS
TypeScript
4
star
22

temp-jquery-foo

JavaScript
4
star
23

web-icons

An investigation into the future of icons on the Web.
4
star
24

jquery-examples

example uses of jQuery
4
star
25

twitter-notify

Node app to display tweets in Growl notifications
JavaScript
4
star
26

connect-oauth-github

GitHub OAuth for Connect/Express
JavaScript
4
star
27

dev-test

feature, bug and performance tests
HTML
4
star
28

hookup

Easily configure GitHub web hooks.
JavaScript
3
star
29

jquery-data-replace

PHP
3
star
30

jquery-colorswatch

jQuery plugin for picking colors from color swatches
JavaScript
3
star
31

node-webkor

mini web framework built on Node.js
JavaScript
3
star
32

j5-shift-seven

Seven segment display controlled by a shift register
JavaScript
3
star
33

jquery-hijax

2
star
34

spawnback

Simplified process spawning with buffered output in a callback
JavaScript
2
star
35

regex-builder

JavaScript
2
star
36

temp-jquery-bar

JavaScript
2
star
37

changelogplease

JavaScript
2
star
38

node-growl

Growl module for node
JavaScript
2
star
39

node-http-extensions

extensions to node's http module
JavaScript
2
star
40

movie-manager

Manage your local movie collection
JavaScript
2
star
41

jquery-littles

Tiny plugins for jQuery
JavaScript
2
star
42

github-event-data

Payload samples for GitHub events available via web hooks
1
star
43

temp-test

JavaScript
1
star
44

gojira

A client for working with the JIRA REST API
1
star
45

es6-to-umd

JavaScript
1
star
46

dco

JavaScript
1
star
47

simple-game

JavaScript
1
star
48

dotnet-bundler

Script and style bundler for .NET
JavaScript
1
star
49

test-jquery-ui

JavaScript
1
star
50

grunt-test

JavaScript
1
star
51

j5-light-display

Customized light displays using Johnny-Five
JavaScript
1
star
52

implicit-pointer-capture

Chrome Extension to make all pointers have implicit capture
JavaScript
1
star
53

simple-log

JavaScript
1
star