Find Jobs
Hire Freelancers

Building a text messaging server in Java (Distributed systems)

$100-200 USD

Cancelled
Posted about 13 years ago

$100-200 USD

Paid on delivery
Problem Description Implement a text messaging server system that can be used for text messaging. Text messages contain a single line of ASCII text, sent to a single user. The two components of this system are; a message server that manages the messages and a client that can be used to connect to the server and then to send and receive messages. The server has been partially implemented and in its current state, allows users to log in and log out from the server. It is lacking the functionality to tell users when they have messages waiting and messages cannot yet be sent or received. In its current form, it can be compiled and run, you can connect it to using telnet and commands 101 and 102 (see below) are complemented. (The code will be given as an attachment.) The server requires a password file to be available and one is provided at the above address. The location of the password file must be configured in the file MsgProtocol.java. The default location is “h:\\[login to view URL]?. ## Deliverables The protocol Here is the definition for the commands that a client may send to the message server: {QUERY} ::= {LOGIN} | {SEND} | {OTHER} {LOGIN} ::= “101?? {CR} {U} {CR} {PWD} {CR} {SEND} ::= “103?? {CR} {U} {CR} {U} {CR} {M} {CR} {OTHER} ::= {ID }{CR} {U} {CR} {U} ::= username {PWD} ::= password {ID} ::= “102?? | “104?? | “105?? | “106?? {M} ::= [ | {M}] {CR} := Note that is any ASCII character excluding control characters and is carriage return followed by line feed which is “\r\n?? in java. Here is a key to the client command IDs: ID Translation Example 101 Login Command “101 \r\n tony \r\n my password \r\n?? 102 Logout Command “102 \r\n tony \r\n?? 103 Send Command “103 \r\n tony \r\n fred \r\n A message to fred \r\n?? 104 Do I have waiting messages? “104 \r\n tony \r\n?? 105 Get next message “105 \r\n tony \r\n?? 106 Get all messages “106 \r\n tony \r\n?? Server responses {RESPONSE} ::= {OK} | {MSG} | {ERROR} {OK} ::= “200?? {CR} {MSG} ::= “201?? {CR} {CR} {MSGDATA} {ERROR} ::= “500?? {CR} {M} {CR} {D} ::= Date {MSGDATA} ::= {U} {CR} {D} {CR} {M} {CR} [{MSGDATA}] Note is an integer with a value greater than zero Here is a key to the server response IDs: ID Translation 200 Request successfully executed 201 n messages are being sent, each message consists of the senders username, the date the message was sent and the message content 500 An error response and the accompanying message should explain the error Examples of java strings for valid responses: 200 “200 \r\n?? 201 “201 \r\n 1 \r\n fred \r\n Thu Feb 27 14:04:32 GMT 2003 \r\n A message \r\n?? or, if there is more than one message: “201 \r\n 2 \r\n fred \r\n Thu Feb 27 14:06:32 GMT 2003 \r\n Hello from fred \r\n?? “fred \r\n Thu Feb 27 14:07:47 GMT 2003 \r\n fred \r\n Another message \r\n?? is the only valid logout command. 500 “500 \r\n Incorrect password \r\n?? Commands 101, 102, 103, 104 will be followed by either an {OK} response or {ERROR} response. Note that for request 104, an {OK} response means Yes there are messages waiting and an {ERROR} response means No messages are waiting. Commands 105 and 106 will be followed by either a {MSG} response or an {ERROR} response. Complete server Classes relevant to this task are: MsgProtocol - The MsgProtocol class defines constants for all of the client and server command identifiers. Use these constants in your code. LoginCommand and LogoutCommand - The LoginCommand and LogoutCommand classes process the login and logout commands. You should look at these classes to see how to implement a command. CommandFactory - This class exists to read the command identifier sent by the client and return a command class that can process the rest of the command. For example, if the command identifier is 101, a LoginCommand class will be returned. Currently command classes are only implemented for logging in and logging out. Command classes to be written You will need to write command classes that handle the remaining commands that your server must process. These commands are: Send a message (103) Are there any waiting messages? (104) Get next message (105) Get all messages (106) Handling messages The classes that are needed for storing messages on the server have already been implemented. These are called Message and MessageCollection. The Message class models the individual messages, has sender, date and content. The date is added to a message automatically. The send message command should construct a new Message object whenever a new message is sent and that message is added to the MessageCollection. The MessageCollection class provides a way of holding all the messages that have been sent but not yet read. Those messages can be accessed using the recipient name as the key. The class has all the methods you will need for adding a new message to the collection, retrieving message for a particular user and finding out how many messages a particular user currently has waiting in the collection. Note that getting a message from the collection also removes it from the collection. You must use the message collection for storing messages on the server. Please do not try and write your own codes to store the messages. Server connections The MsgSvrConnecition class handles an individual connection between this server and a client. It has methods to set the current user and get the current user which all the commands use to ensure the current user is logged on before the other commands work (please see LoginCommand and LogoutCommand). Another method returns the MessageServer object because that object provides access to the message collection. The MessageServer class is the main server class. It knows about the MessageCollection and each MsgSvrCollection. It provides a query that can be used to return the message collection. Distribution issues - Discuss how a JSP servlet implementation of the Text Messaging System would differ from the way it’s currently implemented. As part of your answer you should discuss the system design and a skeletal of class structure and the purpose of each. - Implement a simple interface for the Text Messaging System using JSP and Servlets. Ensure that both the Login & Logout implementation of the system are fully functional. - Your Text Messaging System is proving to be very successful and you are now thinking of partitioning and/or replicating data among servers. Discuss what is involved to run the server on several hosts. Deliverables - Add codes into the client application, modifying ONLY those parts of the code indicated by the comments. - Could you also please ensure that the application runs based on the modified code. - In a plain text file what code has been added, stating what class that code was added to and describing what that code does. - The answers for the question in distribution issues should be detailed showing adequate understanding of design and implementation issues involved in the development of distributed systems.
Project ID: 3281669

About the project

Remote project
Active 13 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs

About the client

Flag of UNITED KINGDOM
United Kingdom
0.0
0
Member since Apr 30, 2011

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.