QuestionQuestion

To properly submit your project for demonstration you must do all of the following:

1) Turn in a hard copy of your source code, including a cover sheet and screenshots.
2) Start (and test) your server and two clients.
3) Demonstrate your application to me.

You are to implement an online Chat/Shared Whiteboard System which will allow users to chat with each other and draw so others can see in real time. Minimally, your system should be implemented to comply with the two following rules:

1) You MUST use the provided ChatMessage class for all communication between your client applet and your server. You are NOT ALLOWED to change the ChatMessage class in any way. If ChatMessage is insufficient for your needs, extend the class by creating a child class that adds functionality.

2) I gave you the skeleton for a basic client-server system. You must convert it and add whatever is necessary to allow your online system to work with your server running in your AFS account. The client will run on a local machine.

import java.io.*;

public class ChatMessage implements Serializable{
public String name;
public String message;

public ChatMessage(){}
public ChatMessage(String name, String message){
setName(name);
setMessage(message);
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
return message;
}
}

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.io.*;
import java.net.*;
import java.util.*;

public class ChatServer
{ public static void main(String[] args )
   {
      ArrayList<ChatHandler> AllHandlers = new ArrayList<ChatHandler>();

      try
      { ServerSocket s = new ServerSocket(4000);
         
         for (;;)
         {
             //Connect
             Socket incoming = s.accept( );
            new ChatHandler(incoming, AllHandlers).start();
         }   
      }
      catch (Exception e)
      { System.out.println(e);
      }
   }
}

class ChatHandler extends Thread
{
    public ChatHandler(Socket i, ArrayList<ChatHandler> h)
    {
       incoming = i;
       handlers = h;
       handlers.add(this);
       try{
            in = new ObjectInputStream(incoming.getInputStream());
            out = new ObjectOutputStream(incoming.getOutputStream());
       }catch(IOException ioe){
            System.out.println("Could not create streams.");
       }
   }
    public synchronized void broadcast(){

       ChatHandler left = null;
       ChatMessage1 cm = new ChatMessage1();
       cm.setMessage(myObject.getMessage());
       cm.setName(myObject.getName());
       cm.setRectlist(myObject.getRectlist());
       ArrayList<String> people = new ArrayList<>();
       if (myObject.getMessage().equals("bye")) {
            for(ChatHandler handler : handlers){
                if (handler.person.equalsIgnoreCase(person) == false) {
                   people.add(handler.person);
                }               
            }
       }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$120.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats