Skip to content

LeanetAlfonso/chatroom-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatRoomServer

Simple chat room server program implemented in Java.

This is a multi-threaded server program that listens on a port for a new connection and maintains a list of all the active connections while synchronizing access to said list using locks.

The purpose of this assignment was to learn about multi-threading and networking concepts.

Protocol for client-server communication

Client Request Server Response Meaning
Join chatroom with valid ID/Username u Welcome message
  • Add client to chat room
  • Broadcast message to all chat room participants indicating client joined the chat room
COMMANDS List of commands
  • Display private message to client listing all commands
LISTALL List of current participants
  • Display private message to client listing all current participants in the chat room (including itself)
COUNTALL Number of current participants
  • Display private message to client indicating the current number of participants in the chat room (including itself)
WHOAMI Current username
  • Display private message to client with its current username
EDITUSER u Username change confirmation message
  • Validate u (no two clients with the same username in a chatroom)
  • Change client's username to u
  • Display private message to client confirming username change
EXIT Exit message
  • Remove client from chat room
  • Broadcast message to all chat room participants indicating client left the chat room
  • Quit the connection
Any other input line after joining chatroom message Chat message
  • Broadcast message to all chatroom participants in the form of “[u]: [message]”

Snapshots

Client A

client-a

Client B

client-b

Client C

client-c

Running Locally (Manual Setup)

Use Eclipse to clone the repository and run program to establish test connection with server.

Use Telnet as client to connect to server.

  1. Install Eclipse IDE.
  2. Open Eclipse and go to File > Import...
  3. In the Import window, select Git > Projects from Git and click Next.
  4. In the Select Repository Source window, select Clone URI and click Next.
  5. In the Source Git Repository window, enter the URI https://github.com/LeanetAlfonso/ChatRoomServer.git and click Next.
  6. In the Branch Selection window, select main and click Next.
  7. In the Local Destination window, enter a local directory and click Next.
  8. In the Select a Wizard to use for importing projects window, select Import existing Eclipse projects and click Next.
  9. In the Import Projects window, select the project and click Finish.
  10. Run ChatRoomServer.Java
  11. Type telnet localhost 3333 at the command line to connect to the chatroom server (you must install Telnet before you can run this command). Run the command from different windows to simulate multiple client connections.

About

Simple chat room server program implemented in Java.

Topics

Resources

License

Stars

Watchers

Forks

Languages