Software Design
Fall 2004

Lab Exercise 11

Due: never!!!

Popups

  1. Download and read

    wget http://wb/sd/code/Popup.py
    
    Now run it. It should create three Popup windows, where each window contains a label and a Close button. Notice that each Popup is running mainloop in a separate thread, so you can interact with the three windows independently.

    When you close all the windows and the last thread completes, the program quits. The object of this lab is to transform Popup so that it can be invoked remotely.

  2. Read RemoteObject.py and then modify Popup.py to define a new class called PopupServer that inherits from RemoteObject, and then define a method named popup that takes a string as a parameter and creates a Popup object that displays the given string.

  3. Modify main so that it creates a PopupServer and then invokes requestLoop on it. When you invoke the PopupServer constructor, you should pass your name as a parameter so that when it registers with the name server, it will use a unique name.

  4. At this point you have a working Remote Object. When you create a PopupServer, it will register with the name server running on ece and then wait for incoming requests. When you hit Control-C, it should unregister cleanly.

    If your program crashes without removing the entry in the name server, you won't be able to restart the program. To remove a name from the name server, start the Name Server Controller by typing:

    /usr/bin/python-pyro/xnsc &
    

    A window should appear. Type ece into the entry labelled Name Server Location, then hit enter. Press the List button to see the names that are defined. If you want to remove a name, type it into the entry labelled Command arguments and they press Remove. You should see a confirmation message in the text field.

  5. Before trying to invoke popup remotely, test it locally. Modify main so that, after creating the PopupServer, it invokes popup on it with a test message.

  6. If that works, the next step is to create a PopupClient that can talk to your server. Start by making a copy of MathClient and modify it so that it takes a name and a message as command-line arguments. It should use the name to look up your remote object and then invoke popup on it, passing the message as an argument.

  7. Start your server in one window and leave it running. In another window, run your client like this:

    python PopupClient.py username "This is the message."
    
    If all goes according to plan, the server should pop up a window to display the message.

  8. Find another student in the class that has a working client-server pair. See if you can get you client to talk to your partner's server, and vice versa. If not, help each other get it debugged.

    Congratulations! You just wrote an instant message system.