Visar inlägg med etikett technical. Visa alla inlägg
Visar inlägg med etikett technical. Visa alla inlägg

fredag 22 januari 2010

Server Side Code

First try with a custom plankton app has succeeded. How to extend plankton and make your own server logic:

Start your java project. Include the plankton.jar library. In your app, import com.plankton.*. Create a new WebServer object. That's basically it. But that doesn't do anything more than running the plankton webserver on it's own.

To insert your own server logic - create a new class that extends com.plankton.WebPage, let's call it myapp.TestWebPage. Do something in the class, let's just write something to the page in the constructor of the class:

write("hello world");

Then, last step to attach it to a plk-file. Add the class reference to the initial <plk> node:

<plk template="template.html" class="myapp.TestWebPage">
... your design ...

Done. Run your app. Surf to your .plk page and the text "hello world" will be printed before any content in the file. My example here

http://worldofcreeps.com:443/plankton.plk

The text I wrote from my custom class is "I'm running the PlanktonTest!!!"

måndag 18 januari 2010

New Times

Nose To Nose

There has not been much development since the summer. I have my reasons. However, just recently I dusted off the old code. I have started to write a new webserver, for now called "Plankton". It is going to be a real lightweight and easy to start/use application for anyone who wants to run a small web without huge memory-and-process-consuming server applications, learning curve and tons of configuration options.

My thought is to also use Plankton for the World of Creeps, replacing the current tomcat/jsp setup. If this works as I intend, I will get rid of an application layer and in the same time make it much faster to develop since I won't be having the trouble with transferring live objects from one java-process to another (The running world -> Web app on tomcat). Web server and world will be the same running application.

The first test with Plankton v0.1b is running on port 443
http://worldofcreeps.com:443/

torsdag 16 juli 2009

Recent Changes Behind The Scenes

Some major structural changes has been made recently. The two most important were moving most of the log, and the opinions, into memory. Previously the log (all creep actions) and the creep opinions were fetched from the MySQL database. However, both these tables were becoming extremely large, and they were crashing more and more often (MyISAM). When I finally moved them to memory instead, the performance boost was fantastic. No more table crashes since this change. And the speed was improved many many times. Opinions and log state are now saved in .dat files instead, making world startup times very fast as well. Overall these changes has made the world much more stable.

The last change with opinions was a limitation. Opinions are growing at a very high rate when all creeps eventually will have opinions about all creeps (and gods). The limit now is that a creep's memory is not infinite. They will be able to remember a limited number of creeps - and when that memory is "full" they will forget the one they met the longest time ago. As for gods, there is no number limit, but a time limit. For now they forget gods after 6 months. Every touch will restart the 6 months period though.

Technical

Ok, a little something for the more advanced readers.

The world is set up on a windows machine (but I plan to move it to Linux).
The important information is stored in a MySQL database.
The world itself, is an application developed in Java.
Currently the world clock ticks every 5:th second.
The web interface is built in jsp / java and runs on Tomcat.
To get fresh information from the world, the interface connects through a socket and fetches real time data.
Both the world app and the web app (interface) uses the same jar file.
In order to present object (creeps, gods, regions, items..) information I have written my own serialization protocol and methods, to avoid overhead.
Dynamic images are constructed from svg originals. I have developed a new lightweight svg library in java to be able to accomplish this.