This is a modified version of the hangman game that is using "HttpResponse::include" to split the game into several parts. Some of the parts are in the csp directory and some are in the html directory.
Since the Barracuda Virtual Directory logic is very flexible and enables one to combine objects in an infinite number of ways, it can seem a bit overwhelming when you first start using Barracuda. The purpose with this version of the hangman game is to introduce you to a more advanced use of the Virtual File System than hangman 1. This version is also in C++.
If you build the example, start the obj/debug/demo program and start a browser at http://127.0.0.1:9357. You should be redirected to the following URL: http://127.0.0.1:9357/Virtualdir/DiskDir/hangman/
The VirtualDir directory exists only in the Virtual File System. The DiskDir directory is the name passed to the HttpResRdr constructor. The hangman directory is the first subdirectory inside the csp directory. You can study the src/InstallVirtualDir.cpp file which creates the Virtual File System for this demo. We named it DiskDir to reflect that you are using a HttpResRdr with a DiskIo object, but you can choose any name.
We have also made the startup code such that the hangman game is at the path: http://127.0.0.1:9357/Virtualdir/ZipDir/hangman/ for a release build. Again, the ZipDir name was chosen to show you that you are using a ZipIo object for the release build.
The index.html file is the default file for a directory. The following two URL's will, therefore, yield the same result:
http://127.0.0.1:9357/VirtualDir/DiskDir/hangman/
http://127.0.0.1:9357/VirtualDir/DiskDir/hangman/index.html
This version of the hangman game consist of the following parts:
If you look at the above files, you will see that all CSP files are stored in the csp directory and all static HTML files are stored in the html directory. The index.html file includes all files dynamically at runtime.
You will see the following code if you open the csp/hangman/index.html file:
The HangmanHeader.shtml is dynamically included, but notice we do not need to use an absolute path. The Virtual File System, which makes it possible to superimpose directories at runtime, automagically includes the "html/hangman/HangmanFooter.shtml" HTML file.
As an example, try to modify the HangmanHeader.shtml HTML file. Pressing refresh in the browser window will instantly give you the new and modified text.
The "include method" in the response object can be used by a CSP page to include static HTML fragments, as shown in this example. These HTML fragments can be updated in a running system and can speed up the design of complex dynamic pages.
The include and forward methods in the response object can also be used as a base for MVC design.