Question: Develop a client server application using stream socket API of Java. This application is intended to support clients ability to store notes on server, and

Develop a client server application using stream socket API of Java.

This application is intended to support clients ability to store

notes on server, and to request notes that have certain properties. Client will have to:

Request a connection with the server

Send different types of messages through established connection:

1. POST

2. GET

3. PIN/UNPIN

4. CLEAR

5. DISCONNECT

Server will have to:

Accept multiple requests for connection

Maintain an appropriate data structure (notes dictionary or board) that holds data received from clients

Process messages received from client:

1.If message is POST , server will have to store the note described in part of the message.

2. If message is GET , server has to send to client all notes stored in the dictionary that satisfy properties described in .

3. If message is PIN , server must pin all relevant to notes.

4. If message is UNPIN , server must unpin all relevant to notes.

5. If message is CLEAR, server must forget all notes which are not pinned.

6. If message is DISCONNECT, server will disconnect from requesting client

is a pair of integers, describing x and y coordinates of a point on the board.

is similar to post - it note (colored rectangular piece of paper containing a string): it

is completely defined by the coordinates

of lower - left corner, width, height, color, message and status

(pinned/unpinned).

If a client would like to POST a note, it must completely define it. For example:

POST 2 3 10 20 white Meeting next Wednesday from 2 to 3

POST

6

6

5 5

red Pick up Fred from home at 5

When notes are originally posted, they are not pinned. To change the status a client can used PIN or UNPIN command. For example,

PIN 4,4

will pin all notes that contain the given pin coordinates. In the example above the first note will be

pinned, while

PIN 7,7

will change the status of both notes to pinned. The meaning of UNPIN is obvious. However, remember that a note can be pinned by more than one pin. So, UNPIN command does not necessary changes the

status of a note.

field in GET command has two forms.

The first one is

GET PINS

Which forces the server to supply a client with coordinates of all pins.

All other requests have the following general form:

color= contains= referesTo=

For example

GET color= white

will force the server to supply a client with all white notes on the board.

GET contains= 4 6

will force the server to supply a client with all notes that contain point

with coordinates (4,6).

GET contains= 4 6 refersTo=Fred

will force the server to supply a client with all notes that contain point with coordinates (4,6) and have substring Fred in the content.

Generally,

GET color= contains= referesTo=

will force the server to supply client with information of all notes of the particular color that contain given by point and has substring in the content.

If one of criterions is missing - the semantics of request is ALL (for example, no color in GET means ALL colors)

Implementation requirements.

Server is a multithreaded Java console application that has multiple command line arguments and starts with empty notes dictionary.

The arguments are in order: , , , , ,...,.

For example, if implementation of server is in successfully

compiled file SBoard.java, then to start server in command line one can execute

>java SBoard 4554 200 100 red white green yellow

which start the server ready to

accept connections on port 4554, supporting the board 200 units wide and 100 units tall

, accepting notes of the colors red, white, green or yellow (with red being default color). Every new client connected to the server will receive a list of available colors, and the dimension of the board of the board upon successful connection.

Servers response to GET type of message is obvious. Servers response to POST type of messages has to confirm the receipt of the note (or send back an ERROR message).

Error handling responsibilities naturally split between server and client and must be described in your document. Also note that the board exist only between server start and shutdown, and does not need to be stored.

Client has to have a GUI. Minimal GUI

requirements are:

Text field to provide IP address of the server

Text field to provide port number

Connect/Disconnect button

Text are a to type in text to be sent to server and POST button

GET button with dialogue to enter required properties

PIN/UNPIN button with a dialogue to supply coordinates

Text area to display result of the request

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!