SlideServe
Menu
Préférences
© SlideServe · v2026

GBK Programming 2 2009-10

metea avatar
9 diapositives · 187 Views · Jul 22, 2014

GBK Programming 2 2009-10. Jordan Johnson Week 1, Day 2. Today’s plan. Greeting Networking, Continued: The Universe Clean-up. Goal. Add networking to the “Sea Battle” game. Requirements: Learn to write client (“world”) programs. Learn to write server (“universe”) programs. So far.

GBK Programming 2 2009-10 - slide 1
01 / 9GBK Programming 2 2009-10
1 / 17

Télécharger la présentation

GBK Programming 2 2009-10
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. GBK Programming 22009-10 Jordan Johnson Week 1, Day 2

  2. Today’s plan Greeting Networking, Continued: The Universe Clean-up

  3. Goal • Add networking to the “Sea Battle” game. • Requirements: • Learn to write client (“world”) programs. • Learn to write server (“universe”) programs.

  4. So far... • “Butterfly” simulation: • Butterfly moves from one computer to another, left to right on each individual screen. • (A butterfly icon is saved on the student server under Programming 2). • Messages: • Server  Client: ‘go(i.e. “You have the butterfly.”) • Client  Server: ‘done(“The butterfly has left me.”) • We’ve written the client.

  5. Review: The Client • To write the client: • Handlers sometimes return a package instead of just a world. • (make-packageworldmessage) • “Here’s the new world, and a message for the server.” • big-bang has new clauses: • on-receive – to say how to handle inbound messages. • register – to specify the address of the server. • name – to identify your world to the server by name.

  6. The Server • The server’s job is: • Keep track of the universe. • Respond to communication from worlds. • More specifically: • Maintain a list of connected worlds. • Add new worlds to the list. • Remove old worlds from the list. • When a world’s done with the butterfly, send the butterfly to the next world in line.

  7. The Server(cont.) • New types of data: • iworld – representation of a world (client) • The “universe” (server’s equivalent of “world”) • A universe is a listof[iworld] • (make-mailiworlds-exp) • A message to the given iworld. • bundle – server’s equivalent of a package • (make-bundleuniverse messages goners) • universe is the new state of the universe • messages is a listof[mail], to be sent to the worlds • goners is a listof[iworld], any worlds the server wants to disconnect.

  8. The Server(cont.) • Starting the server: • universe is the equivalent of big-bang: • (universe u0 (on-new hookup) (on-disconnect hangup) (on-msg listen)) • hookup : universe iworld bundle • How to handle a new world. • hangup : universe iworld  bundle • How to react when a world disconnects. • listen : universe iworld s-exp  bundle • How to behave when a world sends a message.

  9. Clean-up • Before you leave, please . . . • Log out. • Push in your chair. • Make sure you’ve got everything. • Make sure all trash ends up in the trash can.