Server Smalltalk comes with a large number of PingPong examples. The PingPong examples are intended to demonstrate how the facitilities of Server Smalltalk are configured and used to various effects. They are not meant to be representative of any realworld application or to show users how to write their distributed application.
The actual examples themselves are documented in the comment of the class SstPingPong. Below is a summary of how the examples are run. There are separate sections for the IIOP and Java RMI examples as they also require the installation and use of middleware other than SST.
In the example code, replace <ping> with the TCP host and port of the machine you are using as Ping and <pong> with that of the Pong machine. Note that currently the examples do not run with both Ping and Pong in the same image. You can however run two images on the same machine and chose your ports accordingly.
The steps for running the examples vary slightly but generally follow the pattern set out below:
The Java code is in the file sstjava.zip. When unzipping the file, ensure that the directory structure and long file names are preserved. Add the unzip destination directory to the Java classpath. Alternatively, it is often convenient to simply add '.' to the classpath and then change your working directory to the root Java code directory when running the examples. If you are running from within VA for Java, the file must be unzipped and imported into your Workspace. Add the Project into which the code was loaded to the classpath for the Workspace (see the Workspace>>Options menu). Note that running in VA for Java is only practical for the RMI-based examples as the third-party IIOP products may or may not be integrated with VA for Java and so may not use Java code directly from the repository.
Below is a description of how to run the SST Java RMI PingPong examples. The typical case is where one of Ping or Pong is running on a JDK VM and the other is running in VAST with SST loaded. It is assumed that the Java code to be run (i.e., the contents of sstjava.zip) is in the Java package directory structure in the directory D:\pp (substitute your own root here) and that JDK bin directory is on the command path.
Of course, both the Java and Smalltalk examples can be run completely within their respective languages (e.g., Java Ping, Java Pong and Smalltalk Ping, Smalltalk Pong) by combining the above configurations accordingly.
To run the applet version of the client, start the registry and factory as above (or in Smalltalk) and open the file ppapplet.htm in an AppletViewer. Note that the HTML file assumes the root of the PingPong code hierachy is in the same directory as the HTML file itself.
Due to security restrictions, the applet must be signed to run inside the Netscape Browser. To sign an applet you need to download and install the signtool utility (v1.0) available from Netscape Developer website. You also need to have installed a copy of Netscape Communicator on your system.
Generate a Test Certificate
If you already have a certificate from a Certificate Authority then you can bypass this step. Otherwise you can use the command below to generate a test certificate to be used for development purposes
signtool -G <certificate nick name> -d <Communicator's cert.db directory>
Follow the prompt and at its completion, 2 files " x509.cacert" and "x509.raw" will be generated. Note: By specifying the directory of where the cert.db file is, the new certificate is automatically imported into your Communicator's certificate dabase so no extra steps are needed to import it.
Requesting extra privileges
To enable RMI callback, the applet class must import the package netscape.security.* and include the following line in its init() method before any RMI call has been made.
netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");
To compile the applet you will need to include java40.jar in your classpath. This file is part of Netscape Communicator distribution.
Creating a signed jar archive
Make a temporary directory into which you place all the codes that your applet needs. To make a single signed jar file use the command:
signtool -k <certificate nick name> -Z <jarfile name>.jar -d <Communicator's cert.db directory> <temporary dir>
where <temporary directory> is the place where all your applet code resides. This will create a signed jar archive which can be download by the client browser. You will need to add the following parameter ARCHIVE=<jarfile name> in the ppapplet.htm file following the CODE parameter. This is to ensure the client will get the required classes to run the applet.
Making your certificate available to other people
Before other people can grant extra privileges to your applet, they need to have your certificate in their communicator databases. One way to do this is to place the x509.cacert generated earlier in a web page as a web link. Your web server must be able to export this file as the MIME type "application/x-x509-ca-cert".
On the browers which will download and run the signed applet, they need to click on the certificate link. This will bring up a prompt which they will need to follow to import it into their certificate database. Be sure to tick "Accept this Certificate Authority for Certifying software developers" when that question pops up.
Running the applet
When a brower downloads and runs a signed applet, a security dialog box will appear which tells you whether to grant certain privileges which the applet has asked for. The applet is identifed as belonging to a certain organisation whose certificate is in your certificate database. You can then decide whether to grant or deny that privilege.