The world teachpack empowers students to design programs with interactive graphical user interfaces, mostly simulations, animations, and games. The universe teachpack complements world, allowing students to connect two independent world-based programs running on different computers, possibly far away.
A world-based program may communicate with the rest of the universe via messages, which the program may both send and receive.
Message S-expressions sexp?
A message is an S-expression, which is one of:
a char, or
a list of S-expressions.
Note the last clauses includes empty of course.
|(sexp? x) → boolean?|
|x : any/c|
determines whether x is an S-expression.
From now on, each world-producing callback in a world program – those for handling tick events, keyboard events, and mouse events – may produce a Package in addition to just a World.
|world : any/c|
|message : sexp?|
If a callback produces a package, the content of the world field becomes the next world and the message field specifies what the world broadcasts about itself. The world teachpack does not provide selectors for the package structure. [?]
|(on-tick-event tock) → true|
|(on-key-event change) → true|
|(on-mouse-event clack) → true|
|LOCALHOST : string?|
your computer, in IP speak
|(register ip) → true|
|ip : string?|
|(register ip name) → true|
|ip : string?|
|name : sexp?|
connect to the specified server at ip and set up capabilities for sending and receiving messages.
Finally, the receipt of a message from the server is an event, just like tick events, keyboard events, and mouse events. Of course, the world teachpack provides a mechanism for installing a callback for message reception.
|(on-receive-event receive) → true|
tell DrScheme to call "receive" for every message receipt, on the current World and the received message. The result of the call becomes the current world. Because receive is a world-transforming function, it too can produce a package instead of just a world.
The picture below summarizes the extensions