Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Simple Clients

Riccardo Crepaldi edited this page Mar 1, 2017 · 1 revision

Introduction

This document provides a high level view of the Chat Clients for the CodeU project.

The Chat Clients are the client component of a very simple Chat application. The application allows users to read and write Messages that are organized into Conversations. The Conversations and Messages are maintained in a database on a centralized Server, and multiple Clients may connect to the Server to interact with that database. Each CodeU team will build, maintain, and enhance their own version of the Client and Server for their project.

To help the CodeU teams quickly come up to speed, and to provide plenty of room for improvements, this client has a deliberately simple design and user interface, as documented below.

Background

The Chat clients (codeu.chat.ClientMain and codeu.chat.SimpleGuiClient) send requests to a CodeU server (codeu.chat.ServerMain). They work with the same objects that the Server maintains in its internal database: Users, Conversations, and Messages (declared in codeu.chat.common). The client typically maintains a subset of those objects in its own internal data structures in order to present those objects to the user, and to allow the user to create new instances of those objects to be added to the server’s database.

The object relationships maintained by the server are very simple. The server maintains a set of known Users in the system. Each User object represents a user of the system. There is currently no authentication or authorization of User objects, so users of the system may freely create new User objects. Users create and "own" Conversation objects. Conversation objects are containers for a sequence of Messages ordered by their creation timestamp. Users create Message objects, which are always associated with the current Conversation. Beyond creating Users, Conversations, and Messages, users need a way of searching, navigating, viewing, and modifying portions of this simple hierarchy.

Client Design

Two Chat clients are included with the project:

  • codeu.chat.ClientMain is a simple command-line client;
  • codeu.chat.SimpleGuiClientMain is a simple GUI client.

The two clients have their own top-level class (Chat or ChatSimpleGui) which use the same classes to manage their local state and communicate with the server.

Overview

In the case of the command-line client, user commands are parsed by the client’s Chat instance (instantiated in codeu.chat.ClientMain.main()). The GUI client instance is class ChatSimpleGui. The Chat or ChatSimpleGui object holds references to the context objects ClientUser, ClientConversation, and ClientMessage (see below), as well as the server interface objects client.Controller and client.View (not discussed here).

Contexts

The client applications maintain separate contexts for Users, Conversations, and Messages called ClientUser, ClientConversation, and ClientMessage. They represent the set of objects that the user interface presents to the user for viewing and navigating. Contexts are simple and should be extended or replaced to support more complex operations. An important concept when working with contexts is that each context has the notion of a "current" object. The current object becomes the owner or container for new objects. For example, when the user creates a new Message, the Message object is appended to the current Conversation, the Message’s author attribute is set to the current User and the new Message becomes the current Message for future operations.

Client Commands

The set of commands supported by the Chat command-line client are described below. These commands are a minimum set of commands that allow a user to add to view, navigate, and add to the contents of server’s object database.

Basic Commands

help

Display a simple help page.

sign-in

Set the current User. Most commands will not work if no User is signed in.

NOTE: currently, this is strictly a client construct. The server has no concept of current user or being signed in or out.

sign-out

Change the current user to null. The user must sign in again (perhaps as a different user) to continue using the system.

current

Show current User, Conversation, and Message, if any.

exit

Exit the client.

User Commands

u-add <user name>

Add a new user to the server.

u-list-all

The client keeps a local list of all known users, which it periodically refreshes from the server. This command displays this list.

Conversation Commands

NOTE: These commands are somewhat less than a useful minimum set of of commands. However, they do allow any User, Conversation, and Message in the system to be found, viewed, and operated on.

c-add <title>

Start a new Conversation. The current User is set to the Conversation’s owner attribute. The Conversation becomes the current Conversation.

c-list-all

The client keeps a list of all known Conversations, which it periodically refreshes from the server. This command displays the list.

c-select

Select a single Conversation from the list of known Conversations. The command will display the conversations in a numbered list and prompt the user for a number. This conversation becomes the current Conversation for future commands.

Message Commands

m-add <body>

Add a new Message to the current Conversation. The current User is set to the Message’s author attribute. For now the body is a single line of text.

NOTE: This should be extended to support larger and richer message body options.

m-list-all

List all the Messages within the current Conversation.

m-show <count>

Show one or more messages starting from the current point in the Conversation. A positive count goes from older to newer, and a negative count goes from newer to older. Count is optional. If it is omitted, m-show 1 will be assumed. After the command is executed, the current point in the Conversation will be updated to the next message (or previous if the input was negative), so that successive m-show N commands will step through the messages until the most recent (or earliest, if moving backward) is reached.

m-next <index>

Choose the next message for an m-show request. The index is based on 1, the first message of the conversation, or -1 for the last message (and -2 for next to last, etc.).

GUI Client Commands

The SimpleGuiClient supports exactly the same commands as the command-line client. The interface displays three panels, one for Users, one for Conversations, and one for Messages.

User Panel

The User panel keeps a scrollable list of all users known to the server. Selecting a user from the list will present some additional information about the user. The panel has three buttons:

Update

Force a fresh update of the list of users.

Sign In

If a user is selected, make that user the current (signed in) user. Other operations will take place in the context of that user.

Add

A pop-up dialog will prompt for a new user. The new user will be added to the server.

Conversations Panel

The Conversations panel keeps a scrollable list of all Conversations known to the server. Selecting a Conversation will update that conversation’s messages in the Messages Panel. The panel has two buttons:

Update

Force a fresh update of the list of conversations.

Add

A pop-up dialog will prompt for a new conversation title. The new conversation will be added to the server with an empty message list.

Messages Panel

The Messages panel keeps a scrollable list of all Messages within the current Conversation. Selecting a Message does nothing useful. The panel has a single button:

Add

A pop-up dialog will prompt for a new message. The new message will be added to the current conversation.