CST8221编程 辅导、 写作Python,c++程序语言

” CST8221编程 辅导、 写作Python,c++程序语言CST8221JAP,Assignment 2, Part 2,MMXX Page 1 of 9Assignment 2 part 2: Othello NetworkingValue: 8% of your overall grade.Due date: December 13th (Sunday, midnight)Purpose:Weve got the UI sorted out, so lets finish the networking.Were going to build up a server that can handle any number of clients, and were goingto add networking capabilities to our client. When all is said and done, our Othello clientcan connect to our central Othello server, making it much easier to get a good game on.Minimum RequirementsYou will need: A working networking modal from Assignment 2-1, The pink output area as a text area, A menu system of some sort, A text field, and A working Submit button.If youve kept up with the assignments to date, youre in a great position. Keep it up.Changes:There are always changes, arent there?First and foremost, the client should not print a single thing to the console. Remove allSystem.out.println lines. The client is a finished product.Next, the disconnect option and the submit button in your client must start disabled.You know youve done it right when they look sort of grayed out and unresponsive.Finally, you will need to make a few changes to the modal. A new label, Name: A new textfield to take in name input, and Status: should now be blankSee the screenshot on the next page.CST8221JAP,Assignment 2, Part 2,MMXX Page 2 of 9Figure 1: The new Network Connection dialog.The modal will now act differently:If the Address is blank, the Port input is invalid, or the Name has less than threecharacters, make an error message appear on your status label.Figure 2: Network Connection dialog error reporting.The error messages are, Address must not be blank, Valid port ranges are from 0 to65535 and Name must be at least three characters long.Pressing connect will not permit the dialog to close until all input is valid. The usermay press Cancel at any time.(Note: Spelling matters. Plz no spelng mistakes in any messages.)Be sure to correctly use the connectPressed() method already provided in your dialogcontroller.Client ImplementationIf the user has pressed connect (and you can test with connectPressed() in the dialog),the client should attempt to negotiate a connection. If the user has pressed cancel, nomessage is printed to the output area.If the connection has failed, you will want to display an appropriate message to theoutput area.CST8221JAP,Assignment 2, Part 2,MMXX Page 3 of 9Figure 3: Client reporting a failed connection.If you do succeed in connecting, a Connection successful message is useful.Immediately launch a new thread (details below) to manage the client connection.Figure 4: Successful connection.Note that New Connection is now disabled, Disconnect and Submit are now enabled.We are now live and connected to the server.CST8221JAP,Assignment 2, Part 2,MMXX Page 4 of 9Typing messages in the text field at the bottom, and then clicking Submit, will transmitmessages to the server. Selecting Disconnect from the menu should disconnect fromthe server.Class OthelloNetworkControllerYou will need a new class, OthelloNetworkController, which will be a thread. This threadwill monitor the socket, and when it detects input, promptly displays it on the outputzone.Figure 5: Sent a command to the server and received a response.Upon connection, the thread will pass the name youve provided to the server. You canuse /name for thisdetails to follow in the Server section of this document.If the socket should close abruptly, or any other error should occur, it will close itselfdown gracefully. New Connection, should be enabled, Disconnect, and Submitshould be disabled.CST8221JAP,Assignment 2, Part 2,MMXX Page 5 of 9Figure 6: Disconnected.The ServerThe server will do much of the work in this assignment. It will have no UI and it operatesstrictly from the command line. It will print status updates to the console as it goesalong.The server will be in its own package, server, with a lowercase s.The server should produce useful output as it goes along. Specifically: When a socket is first created, number it sequentially and print to console. When the thread is created and the user is first named, print that to console as(username) has connected. If a user has disconnected from whatever means, a disconnection message isrequired. Finally, if a user renames themselves, the old and new name should appear: (oldname) has renamed themselves to (new name).CST8221JAP,Assignment 2, Part 2,MMXX Page 6 of 9Figure 7: Server in operation with sample messages.Class: OthelloServerThis will serve as your entry point. It will accept a command line argument for a portand parse it. I should be able to run this server on any valid port. If the input is invalid, itwill default to port 62000Figure 8: Server launchThe server should create a Server socket, monitor it on a loop, and create anOthelloServerThread to manage that specific connection. It should also keep track ofthat OthelloServerThread in a threadsafe manner.It must also announce to the console when a new user has connected,CST8221JAP,Assignment 2, Part 2,MMXX Page 7 of 9Some suggested methods:broadcast(String): Broadcasts the given message to all existing threads.remove(OthelloServerThread): removes this thread from the list. Useful when a giventhread has disconnected one way or another.who(): returns a list of the names of all currently connected clients.This list is not exhaustive. You will need to make a method that broadcasts to allconnections save the one that issued that event. (ie: for /name functionality)Class: OthelloServerThreadThis class is responsible for monitoring the actual socket. If the user enters certaincommands (they all start with the slash/) then a special command will occur.Otherwise, it is a text message to be broadcast to all users who are connected.There are four commands that must be implemented: /help will display a help message. See Figure 5, above. /bye will make the server disconnect the client /who will return a list of all connected users to the client, and /name (newname) will permit you to change your name.Figure 8: Who is on my server? I am! Twice!CST8221JAP,Assignment 2, Part 2,MMXX Page 8 of 9Figure 9: Name changing is getting out of hand.Some specifics on /name: The user that initiates a new name change should get aserver message: Name changed to (new name). Every other connected client shouldsee, (old name) has renamed to (new name).Likewise, both /help and /who should only report to the user that sent the command,not to all clients.Helpful hint: setName() and getName() are reserved methods in a thread. Youll have tocall them something else. While you could override them, I dont suggest it for thisassignment.Final advice:Plan your code. While the server code isnt as intricate as OthelloModel was, there are afew complexities involved, and having a plan will help.Your client and your server should not be throwing exceptions. Several networkoperations will require you trap specific exceptions; this will let you handle abruptdisconnections gracefully. Have your Client report useful error messages to the userwherever possible.Test your code. Connect with multiple clients. Close the server abruptly with CTRL+C, orjust shut close a client without disconnecting. If either the client or server throws anexception when you do this, read the stack trace, find where the exception occurred, andadd a catch statement to handle it gracefully.I will be running my version of the server from time to time, generally during my labhours (refer to my schedule in Course Information). You can test your client against it ifyour router and firewall permit it. (IP: 69.196.152.225, port 21438) Because of how myCST8221JAP,Assignment 2, Part 2,MMXX Page 9 of 9server works, telnet will not connect to the server properly and your connection will bedropped.Connecting to my server is not strictly necessary. Connecting to your own is, of course.Roughly 60% of the marks in this assignment marks are in the server.Useful material for this assignment will be covered in lectures. Do attend. Youll find ituseful.Finally, there can be no extensions on this assignment, it is literally as pushed-back as Ican make it. A half-working assignment thats late is worth some marks, but I can notaccept a late submission at all. Get on it early.BONUS MARKSThere are a chance to earn a few bonus marks. These will only be available if yourserver and client work wellif I can connect to a server, transfer messages, executeserver commands successfully and have no exceptions thrown under normalcircumstances, then youll qualify.As these are bonuses, they will be held to a higher standard of marking. In all cases,provide a readme.txt file detailing what bonuses you are attempting, and a bit ofimplementation detail. You dont need an essay, but I should have a clear idea whatyoure doing. A paragraph or two will generally do. You may need to update the /helpcommand as well.Bonus 1: Emote messages (easy)If a user types /emote (message), it should appear without the colon. For example, if Ido /emote is marking assignments, everybody connected will see, Daniel is markingassignments in their clients, as opposed to Daniel: is marking clients.Bonus 2: Unique Names on Server. (medium)Theres nothing stopping three people from having the same name. You should enforceunique names. Specifically how this is enforced is up to you. An already-connected usergets priority. (ie: you cant be Daniel on my server if Im already Daniel).Bonus 3: private messaging (hard)If a user types /pvt (user) (message), the user named (and only that user) shouldreceive a private message (message). If the user cant be found, the user will get auseful error message. You may need to restrict user names and name changes in somemanner. Detail those specifics in your document as well. It doesnt need to be an essayor anything.Have fun with this assignment. Theres still a lot of implementation and expansion thatcan be done. Make this truly your own piece of code, and remember:There is no tennis without a serve, and no client without a server. Anonymous SwingProgrammer.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导