Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help with this java question. I provided my code import ocsf.server.AbstractServer; import ocsf.server.ConnectionToClient; public class ChatServer extends AbstractServer { public ChatServer() { super

Can someone help with this java question. I provided my code

image text in transcribedimage text in transcribed

import ocsf.server.AbstractServer;

import ocsf.server.ConnectionToClient;

public class ChatServer extends AbstractServer

{

public ChatServer()

{

super(12345);

}

public void handleMessageFromClient(Object arg0, ConnectionToClient arg1)

{

}

public void listeningException(Throwable exception)

{

}

public void serverStarted()

{

}

}

public class TestChatServer

{

private ChatServer server;

public TestChatServer(int port, int timeout)

{

//Instatiante server

//Set port for server

//Set timeout

//Start listener (try/catch)

}

public static void main(String[] args)

{

int port = Integer.parseInt(args[0]);

int timeout = Integer.parseInt(args[1]);

new TestChatServer(port,timeout);

}

}

ChatServer Implement a Java Class named ChatServer (ChatServer must extend AbstractServerMake sure that "Implement abstract methods" is selected when creating the ChatServer class The method description for ChatServer is given below public Constructor for the ChatServer. The port data field should be set to 12345. The timeout data field should be set to 500ms argl) public void Slot method that is invoked whenever the client sends a message to the server. For now, the method can simply display on the Console "Client Message sent to Server" Object arg, public void listeningException(Throwable exception) Hook method that is invoked whenever an exception occurs while the Server is listening for clients to connect. For now display the following messages to the Console 1. Display a message "Listening Exception Occurred" 2. The actual message set by the system within the exception input parameter 3. The stack trace associated with the eception input parameter public void serverStarted) Hook method that is invoked once the Server is successfully listening for Clients to connect. For now, display the following message to the Console "Server Started" TestChatServer Implement a second class named TestChatServer. The TestChatServer class should declare the following datafield private Chatecvec servers And implement only the following 2 methods: public estChatServerint port, int timeout) Constructor. Accepts two input parameters - the port and the timeout. This Constructor should perform the following steps 1. Instantiate a ChatServer object using the default Constructor. 2. Set the port data field of the ChatServer object to the value of the input parameter port 3. Set the timeout data field of the ChaiServer object to the value of the input parameter timeout. 4. Invoke the listen method on the ChaiServer object public static void main(String] acgs) Accepts 2 command line arguments stored in acgs input parameter: acesLe] -> port # for the Chaseryer. acgsl1] - timeout value for the ChatServer These 2 values must be passed into the ChatServer.Constructor Test your program using a Web Browser Since we don't have a Java Client implemented yet, perform the following steps to test this version of your ChatServc: 1. Start your ChatServer with a port # and a timeout value (port # and timeout are provided from the Command Line) Open the Web Browser of your choice 2. 3. Type the following in the address bar of your Web Browser: 127.0.0.1:port no Note: RR role-is the port # you started your 4. A listening Exception will be thrown by the ChatServer because the Web Browser is not a Java Client

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

what is the formula for Gold ( II ) acetate

Answered: 1 week ago

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago