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

Down and dirty Commanche basics

This was to be a "how to make Commanche work with 3.8" tutorial, but the packages from SqueakMap seem to work just fine now.

Instead, I will give you a very basic framework to set up some webserver-like functionality in Squeak. I'm not talking about serving files or a hello world page. That is the bollocks I've found and it is not all that helpful. I'll teach you how to parse requests in a simple, yet effective way, and give you a somewhat theoretical framework to implement these ideas in order to serve up either static or dynamic pages, your choice.

But, first things first.

Lets set up Commanche!

Uploaded Image: open.jpg
Uploaded Image: package_loader.jpg
Uploaded Image: view_loader.jpg

File Out The Super Secret Commanche Dependencies!

Uploaded Image: dependency_fileout.jpg

File Out Your Project

Uploaded Image: all_fileouts.jpg

Making a Webserver

| ma |
	ma := ModuleAssembly core.
	ma documentRoot: FileDirectory default fullName.
	ma directoryIndex: 'index.html index.htm'.
	ma serveFiles.
	(HttpService startOn: 8080 named: 'Example') plug: ma rootModule

That would be a rather worthless http-based file server. I'm sure your projects will require something more . . . sophisticated.

| ma |
	ma := ModuleAssembly core.
	ma addPlug:
		[ :request |
		HttpResponse fromString: 'Hello world!'].
	(HttpService startOn: 8080 named: 'Example') plug: ma rootModule. 

I can see by the sneering gesture on your face that you are not that impressed. Neither was I. That's great that I can start a server and it says hello world back to me all day long, but it would be nice if it were useful.

No problem. Here's the word on what you need to know.

Make it Happen

The classes

Object subclass: #SPServerLauncher
	instanceVariableNames: 'theServer theProcessor'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'SqueakPoint-Server'

Object subclass: #SPhttpProcessor
	instanceVariableNames: 'potato'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'SqueakPoint-Server'

Try it!

This should be everything you need to get up and running with Commanche. If you want to know more about our implementation, check out Team T34M's M5.

Links to this Page