Giter Site home page Giter Site logo

simple_chat's Introduction

SimpleChat

A very simple socket-based chat application built in Ruby.

Design

The program design loosely follows a publish/subscribe pattern whereby one or more clients establish a connection to a central server. Upon establishing a connection, clients can send messages to the server, which are then broadcast to any and all connected clients listening on the same channel.

Something like what is illustrated in this beautiful diagram:

server-client diagram

Got it? Good.

Usage

Two binary files are provided: one to run the chat server, and one to run a client session.

Server

To run the server, execute bin/server from the app's root directory.

$ bin/server

Simple Chat server is running.
Listening for connections on HOSTNAME:PORT...

It also accepts options to specify the hostname and port.

$ bin/server -h my_computer.local -p 7777

Simple Chat server is running.
Listening for connections on my_computer.local:7777...

Client

To start a client session, execute bin/client from the app's root directory.

$ bin/client

Welcome! There are N people online.

In addition to specifying the hostname and port to connect to, you can also provide the client with a name, which will be used to identify the client.

$ bin/client -n my name -h my_computer.local -p 7777

Welcome! There are N people online.

Thus, when another client connects to the same server, messages are prefixed with the sender's name.

simple_chat's People

Contributors

tannerwelsh avatar

Watchers

 avatar

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.