Skip to content

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

Notifications You must be signed in to change notification settings

mjseaman/simple_chat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%