Giter Club home page Giter Club logo

jschat's Introduction

JsChat is a chat system. It has an easy to learn JSON protocol, an ncurses client, a web app, and a server. You can try it right now on jschat.org.

JsChat is similar to IRC, but it’s a fundamentally simpler system.

The web app has lots of interesting features:

  • IRC-like commands: /names, /name new_name (/nick works too), /clear, /lastlog
  • It’s pretty tiny; it’s built with Sinatra and Prototype
  • Auto-linking: pasting an image displays it inline, youtube and vimeo videos will appear as well
  • Last messages are displayed on join: the last 100 messages are displayed, so you don’t feel lost when you join a room
  • Tab completion!

Installation

You can install with rubygems:

gem install jschat

Then run jschat-server and jschat-client to try out the console client locally.

To try out the web client, run jschat-web and visit http://localhost:4567.

Ruby Library Requirements

These gems are required by JsChat:

  • eventmachine
  • ncurses (for the client)
  • json

Usage

  • Run the server with ./server.rb
  • Connect a client with ./client.rb

The web app must be run alongside the server. The web app must be started in production mode:

http/jschat.rb -e production

The web app currently has no database dependencies, it’s a wrapper that links cookies to JsChat server proxies. You can run it on port 80 by configuring Rack or an Apache proxy. I have Apache set up this way on jschat.org.

Configuration Files

These are the default locations of the configuration files. You can override them with --config=PATH:

  • Client: ~/.jschat/config.json
  • Server: /etc/jschat/config.json

The web app will use the same configuration file as the server so it can find out where the server is.

The file format is JSON, like this:

{ "port": 3001 }

Server Configuration Options

{
  "port": integer,
  "ip": "string: IP address to bind to",
  "tmp_files": "string: path to tmp files (including PID file)"
}

Client Commands

  • Change name or identify: /nick name
  • Join a room: /join #room
  • Join a room (alias): /j #room

Protocol Design

The protocol is designed to be as close to executable JSON as possible, so clients and servers are simple to implement.

Look at client.rb JsChat::Protocol to see what I mean.

Hey, this is like Campfire!

I love Campfire and I didn’t intend for JsChat to compete with it. JsChat is just a fun project, it doesn’t offer Campfire’s business-friendly interface, file hosting, transcripts and Basecamp integration.

Credits

JsChat was created by Alex Young for Helicoid. A growing group of friends are helping out:

If you’d like to contribute, send alexyoung a message on GitHub.

jschat's People

Contributors

jenf avatar nickmartini avatar sstarr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jschat's Issues

Sinatra app structure

The http client should be structured better so it can have separate js and template files

Room names management

Rooms in the client should be properly modeled, with a list of names that changes on join/quit/part

Validate channel and nick names

The server should validate channel and nicks. We could block all control codes except colour so people can have colour nicks.

hash could be reserved for room names, this would allow messages to be routed to users or rooms, solving private messaging easily.

Client command parsing

The regex is daft: it will parse the command from any point in the string, not just the start

Wall

There should be an admin wall command to message every channel

Resize

window resize should work

Identify

Identify protocol response should be defined

Links and images

The http client should auto link links and show image thumbnails. It's probably best to do this client-side.

Loading indicator

The sign on page should have a loading indicator, so nick doesn't gluahglauhg the server

History stack size

The web app should clear over X hundred lines to prevent the app effectively becoming a memory leak.

Resizing/refresh messes up text

I'm not sure, but it seems to mess up the order of the history as it's reprinted

also the history should be a queue rather than infinite list

Nick change notifications

  • "identify" shouldn't be used for nick changes
  • There should be a specific change request for this
  • Notifications should be sent to the people in a room
  • The web app should displays these and refresh the /names list

JavaScript text parsing

  • -The link and image parser should tokenize strings so multiple will work better-
  • -Open links in a new window-
  • Also, add asterisk for bold and underscore for italic (like textile)

Strip

Be less judicious with strip: white space is currently being lost from the console client for one, but newlines need to be stripped at least.

Multiple tabs

Due to the way cookies are used multiple tabs will confuse the client. When the cookie is present it should do something sensible:

  • Cause you to leave the room, or
  • Forward you back to the room

Flood protection

Server needs to track message send frequency to prevent flooding:

  • Slow down messages after X repeats
  • Throw away messages after Y and return error

History

Pressing up/down should cycle through history like readline

Message length

  • A message length should be decided
  • The server should truncate message bodies over a certain length
  • If a data line is too long it should be refused
  • The web app should have the length set as the maxlength in the form field

Web interface error handling

Disconnections

Catch disconnections, stop polling and display an error. Causes:

  • Cookie issue
  • Jschat server goes down
  • Sinatra EM server that holds connection to jschat is lost
  • Sinatra is restarted

Jschat Protocol Errors

Errors from the real jschat server should be displayed within the chat transcript.

Chat Page Refresh

It should be possible to refresh the chat page without losing the connection. The lastlog should be displayed.

HTTP client should accept, send and process commands

/names - refresh name list in case of issues
/name or /nick - change name (with suitable error handling)

Other ideas:

/j or /join - could technically open a new window at chat/#room but it this isn't that important for now
/p or /part

sending "/" causes a client crash

I guess it was dumb of me to do that.

./client.rb:149:in strip_command': undefined method[]' for nil:NilClass (
from ./client.rb:134:in manage_commands' from ./client.rb:77:inreceive_data'
from /opt/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.6/lib/eventmachine.rb:240:in run_machine' from /opt/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.6/lib/eventmachine.rb:240:inrun'
from ./client.rb:183

Room logging

The server should log the last X messages

The HTTP client should be able to query this and display them after connecting

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.