项目作者: sgtb3

项目描述 :
A multithreaded client-server chat application
高级语言: Java
项目地址: git://github.com/sgtb3/CL-Client-Server-Chat.git
创建时间: 2016-03-29T00:06:50Z
项目社区:https://github.com/sgtb3/CL-Client-Server-Chat

开源协议:

下载


Contents

This directory contains a command line chat room application. The user needs to
supply a file containing valid usernames and passwords that hosts can use to
log in. A default set has been provided. Do not change the file name. A Makefile
is also provided.

Server.java

  • Needs to be run before the client.
  • Handles multiple, simultaneous clients.
  • Contains a thread running concurrently, checking for inactive clients.
  • Handles interrupt signals and terminates connections gracefully.
  • Parses each line looking for the proper format for commands and
    will display an error message is the user’s input does not conform.
  • Has functionality to block unauthorized users for a certain amount of time
    (60 seconds by default).
  • Has functionality to save and display offline messages. If a client
    receives either a group or private message while offline, the server saves it
    and displays it to the client upon logging in. It then deletes those messages.

Client.java

  • Each client has their own thread to communicate with the server and runs
    forever until either the server is shutdown, which in turns disconnects the
    client, or the client terminates - either through an interrupt signal or
    using the logout command.

Makefile

make compiles the source files

make clean will clean all auxiliary files.

UserPass

  • Contains only those usernames and passwords credentials that a client will be
    able to use to log in.
  • Needs to be in plain text and can only contain alphanumeric characters,
    else it will display an error message and shutdown to allow for correction.
    Once the server is started, it will hash these credentials using the SHA1
    algorithm and replace this file with another file with the same name. The
    original file will be renamed to “UserPass.OLD”. The hash will also be formatted
    in hexadecimal. Credentials need to be provided in the following format:

    1. <username> <password>
    2. <username> <password>
    3. ....

Build and Run

  1. make
  2. java Server <server port>
  3. java Client <server address> <server port>

Usage

An example after successfully starting the server and client, and successful
authentication (user):

  1. help
  2. commands:
  3. who
  4. last <number>
  5. broadcast <message>
  6. send <user> <message>
  7. send (<user> <user> ... <user>) <message>
  8. logout
  9. who
  10. [user]
  11. broadcast hello
  12. last 10
  13. [user]