Flash Multiplayer Virtual Worlds
上QQ阅读APP看书,第一时间看更新

Using embedded web server and database

We are going to play with the embedded web server and database. The embedded web server and database are well-configured and run on startup by default. This lets developers rapidly develop the prototype of the virtual world without worrying about setting up different servers.

Running the embedded web server

By default, the web server is running on port 8080 with same SmartFoxServer location.

After starting up the SmartFoxServer, go to http://localhost:8080 in the web browser. If a webpage shows up with a message "SmartFoxServer Pro 1.6.6 is installed successfully", it means the server is working with default settings.

The HTTP documents directory of the embedded server is located in Installation folder | Server | webserver | webapps | root. You can modify and store static web pages within this folder to host the virtual world website.

Running the embedded database server

The embedded H2 database server is well-configured upon SmartFoxServer installation.

Windows users can launch the H2 Database Admin Tool by double-clicking the adminDB.bat, which is located in SmartFoxServer installation directory | Server. Linux and Mac users can launch by executing the following command in the terminal in the Server directory:

chmod +x adminDB.sh ./adminDB.sh

After executing the adminDB script, a web interface of the Admin tool will open in browser.

We will use the default saved settings to connect the H2 database. In Windows and Linux, the default setting is Generic H2, while in Mac, the setting is called Generic H2 (Embedded).

If the development is based on H2 Database engine, we can test the database by clicking the Connect button with default settings.

After connected to the H2 database engine, the admin panel is divided into three parts. The upper part contains action buttons for operating the database such as the logout or execute commands. The left part lists all available users and tables. The right part is for inputting the SQL commands and viewing the results. H2 database is a light-weight engine that we need to operate the database by typing all the SQL commands ourselves.