View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

A Simple How-To Guide for a PWS Server

created by Nick De Jesus (of Team More Powerful Than Superman, Batman, and Spiderman Put Together)

Why do this page? Well, for starters, PWS is lot easier to handle than Comanche, even though it may not have as much potential. For simple service like hosting a minor Squeak Server, it fits the bill just fine. Secondly, there are already enough pages on Comanche, and none for PWS. This is to help the PWS-using people out.

B)What You Need
1)Make sure you are running the correct version of Squeak. I have heard ‘claims’ that it runs on the most recent version, but I have personally experienced errors on any version past 3.7. You can try it for yourself (the code remains the same), but you’ve been warned.
2)You must File In all PWS .st files,,,,, and Keep in mind you do not technically USE all of these files, but Squeak sometimes gets angry if they are not all there.
3)You must make sure all of the pages (usually .html files) are in the same directory as Squeak (the one you running now). Otherwise, upon testing, Squeak will pop up saying your pathname is invalid, and ask you to correct it, and it will also bring up the serverDirectory method (convenient!). In this case, delete whatever its returning, and write in the complete address to the folder your files to go on the server are in. However, just save yourself the trouble and store all of your stuff together.
4)Make sure your project file is open, and prepare to add some more classes.

C)The Process
1)You’re going to make 3 new classes, the Server class that will start the whole thing, an Action class to override the default one, and an additional Action class to perform some other action. For this demo, I will name these classes, ServerStart, PPTAction (could be FooAction), and PPT1Action (could be BarAction).

2) For the StartServer, have 2 method categories, ‘initialize’ and ‘stop’. The purposes of these are self-explanatory. In Initialize, follow the code below:
Uploaded Image: Squeak1.jpg

Note how we have Port number 8080. It can actually be almost any number above 1024 (ex: 2222).

3) Next, the important method, Stop… otherwise it won’t stop and that presents problems:
Uploaded Image: Squeak2.jpg

4)Next Class will be PPTAction. Look at the screen below and note the comment. The purpose of this class is merely to act as a local default for the server in case anything breaks. In actuality, it’s a carbon copy of the serverAction class in PWS-Kernel with a slight name change. (copy the class as insurance)
Uploaded Image: Squeak3.jpg

5)Now, for the real action. As you may or may not know, Squeak can run HTML in its code, or vice versa (its called CGI scripts, very handy). What you have the option of doing is creating is ADDITONAL actions for your server to perform.

Now, what is an Action? In lay man terms, think of it as a single page, where the name of the action is the ending URL of the page. (ex: an action names Foo would be linked to the page Foo.html). Most sites have more than one page, hence why you want more than your default Action (PPTAction).

Thus, PPT1Action was created. Inside this class there is only 1 method (you can name a method category if you want, but it does not matter), and inside this method is the following code:

process: aRequest
aRequest reply: PWS success.
aRequest reply: PWS contentHTML, PWS crlf.
aRequest reply: '...'

where ‘...’ is any HTML code you would otherwise have in a webpage. Use this to link to the index or stariung page on your site. If you go back to the ‘initialization’ method, note how (in comments) there is the code:

PWS link: 'index.html' to: PPT1Action new.

This creates the action, ‘index.html’ which means whenever the page index.html is brought up, it will run whatever code is in PP1Action.

And that’s all there is to it!

6).Now, to run this thing, if your server is named StartServer, simply type (in a workspace or wherever):

Startserver new.

And ‘Do It’ on that. Now find out your computer’s IP address, go online to http://(your IP address).8080/index.html and there is your page. Congats, you’re done!

D)Things To Watch Out For

PWS initializeAll

to install all of the files.

StartServer stopServer

when you’re done!

Link to this Page