CSC152 2004F, Class 35: Weekly Project Discussion Admin: * It is bad to miss the weekly project discussion, even if you trust your groupmates (hint to BillupsM, ConorKev, BeckingE) * Questions on the exam? Tomorrow is your last real chance. * Don't forget to vote! * PolySci party tonight! * Grade our homework, please! * Grade 223 exams * Prepare classes * Write paper * Grade 152 homework Overview: * Network group presents * CRC card discussion /Network Group/ * Code can be found in /home/poythres/CS152/Project * Servers: * Create a ServerSocket * Accept on that socket * Build input and output * Use as normal. /Sam attempts to record the board/ * UI communicates with anything that can implement the World interface * Two implementations of World * The real implementation * The network client implementation * World provides two important methods (so far) * interact(String actor, String verb) * interact(String actor, String verb, String object) * UI reads user input, validates it, calls appropriate interact method * Client packages up user input, sends it to server * Server reads and unpackages users input, calls interact in RealWorld * RealWorld validates action * If the action fails, RealWorld throws an exception * Server catches the exception and sends an exception object back to the client * Client reads exception object and throws an exception * UI catches exception and prints error message * Suppose the action is SAM GET TAPE, which is legal * RealWorld informs room that tape is no longer directly in the room (remove(thing)) * How does room know what room Sam is in? * RealWorld informs Sam that he now has the tape * RealWorld identifies all the people in the room (by calling the contents() method) and tells them about the action. * We do this because the AI people will need to know about actions * RealWorld tells all clients about the action (see below) * RealWorld returns "Sam now has the tape" (or something similar) to server * Server sends the reply back to client * Client reads, unpacks, and returns to client. * To inform all clients about an action, RealWorld calls the sendMessage() method in server. * The server compiles a list of clients and sends a message to them * Each client gets the message and calls the showMessage method in its corresponding user interface * Rather than having methods that parse or unparse the action, we've decided to have a separate rebelsky.mug.Action object.