DOC PREVIEW
Duke CPS 108 - Notes

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Software Design14.1Networked games: ooga to noogaz Different games make writing general server difficult¾ Turn based games…¾ Multiplayer asynchronous games like Boggle…¾ Noah’s Ark, Samegame, …z Nooga story at Duke¾ Each summer for the past N summers …• Do we have a general, usable architecture?¾ What should we do next?z What are key issues in developing networked games¾ Don’t worry about robustness or generalitySoftware Design14.2multi-platform, multi-os client/serverz Suppose we send data between clients and servers…z Architectural issues impact client/server code¾ Little-endian/Big-endian issues• 0xabcd is a 32-bit value, which is MSB? How is this stored?¾ How big is an int? 32-bits, 64 bits, …z Towards raising the level of discussion¾ Worrying about integer byte order is not fun ¾ Let’s worry about sending objects back-and-forth, not bytes¾ How do we send and receive objects?Software Design14.3Client/Server Communicationz The Java stream hierarchy is a rich source of options¾ Object streams, Data streams, Buffered Readers, …¾ Often these convert between bytes and characters• What’s the story with Unicode? (e.g. compared to ASCII)• FileStream, BufferedReader, …, z We can read and write objects over sockets¾ Advantages compared to lower-level protocols?¾ Disadvantages?z Issues in understanding and implementing¾ Where do objects “live”, are classes different?¾ Subclass/Superclass issues¾ What about connection issues (where, how, knowledge)Software Design14.4Clients and Servers: server sidez Server socket exists on some machine, listens to a “port”¾ A port isn’t a physical concept, it’s an OS concept¾ The OS manages ports, some services listen at predetermined ports, e.g., mail at port 25• User programs use ports above 1024z Server gets a connection and handles the request, but what about other connection requests?¾ Can’t be too busy processing request, or will miss other attempts at connections¾ Spin off handler as a separate program/process z Server blocks on accepting connections, new jdk1.4 API for java.nio.channels might improve things¾ Why is blocking not ideal?Software Design14.5Networked Gamesz What will go over the network?¾ Board?¾ Move?¾ Other?z Where is the controller?¾ Server?¾ Client?¾ Combination?z How does the server work for many games?¾ Rules important?Software Design14.6Simple Client/Server codez The example shows how a client communicates commands to server¾ Deciding how to process a command is simple, but not robust/OO in the current modelz How are client and server similar? Different?¾ Both know about all commands?¾ How do they know this?Software Design14.7Architectural considerationsz What can we do to generalize things, move away from chain of if/else code¾ Create commands corresponding to protocol¾ Execute command obtained by mapz What’s in the map? Some commands require state, e.g., more data from server or client¾ Can have a map of string to object, but how to get information into the object?¾ Can map string to object factory, have a per-command factory¾ Factory knows how to create each


View Full Document

Duke CPS 108 - Notes

Download Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?