How DimensioneX works – 5
Posted on Jan 12, 2015 | 0 comments
1.2.13 Server-Side Hooks
DimensioneX offers a way to integrate any game with external applications.
You can use the HOOKS tag to:
- Export game data as an XML feed
- Integrate your game with external on-line shopping carts or e-commerce/e-payment procedures
- Integrate your game with Google Toolbar Buttons
- Integrate your game with virtually ANY web-based application
HOOKS defines commands that the game server will accept from the outside, regardless of the state of the client (in-game player or not). Each command you specify in the HOOKS line will be associated to an event defined by you. Then, in the event code, it will be up to you what to process and what to output.
1.2.14 mySQL Support
Game settings are normally saved on disk in text files with .sav extension. In production servers, performance could be improved by using a mySQL database instead.
DimensioneX is capable of using a mySQL database for storing data transparently to the user. The connection is automatically created for each use and, if a failure occurs, the game engine will switch to ordinary file-system based behaviour hence allowing the users to continue playing. Specific events (onDbDown/onDbUp) will notify your game about this so that you can temporary disable save game function, inform users, etc.
To activate mySQL support, you have to:
- Create an empty database on any mySQL server
- Configure the dimensionex server to be aware of it. You must configure credentials for a user that is capable of creating tables and writing to them.
- Run the Check Database / Initialize function from the Maintenance Panel – See section about Maintenance Panel below for more details.
The Maintenance page offers utilities:
- To check database connection and diagnose problems. This procedure also initializes the tables for their first use: A table for each game is automatically created, and values are automatically loaded by taking them from the existing .SAV file, if any.
- To easily load data from the SAV file into the mySQL database, and the converse export operation.
It is recommended, though, that the server admin uses some other specific tool (such as phpMyAdmin) to back up the database and/or backup its content in production installations.
1.2.15 Output to RSS feed – integrating with Facebook, Twitter and other social networks
DimensioneX offers a way to publish the most important in-game events to a standard RSS feed. From there, this information can be easily distributed to the interested audience, either via standard RSS feed readers and browsers, or via Facebook, Twitter and any social networks.
- Piping an RSS feed to a Facebook or Twitter account, or to a Facebook page is easy by using available free services such as Twitterfeed.com and RSS Graffiti. The use of such services is beyond the scope of this documentation but you can ask more details on the support >Forum.
In order to produce this RSS feed, DimensioneX lets you produce a Journal file which is actually a text file in which events are listed recent-to-old order, one per line.
The journal file which is managed by the system to list the 20 most recent events, is a pipe-separated plain text file. An example of journal file produced by DimensioneX follows:
Thu, 26 May 2011 12:56:24 +0200|Cris rules the Kingdom!|http://www.underworld-game.net/infobox.php?id=cris&lang=eng|There is a new King in Underworld:\n<a href="http://www.underworld-game.net/infobox.php?id=cris&lang=eng" target=_blank>Cris</a>!|news,kingdom,user:Cris
Thu, 26 May 2011 00:39:13 +0200|Sir Duncan governs Underworld|http://www.underworld-game.net/|There is a new King in Underworld:\n<a href="http://www.underworld-game.net/infobox.php?id=sir_duncan&lang=eng" target=_blank>Sir Duncan</a>!|news,kingdom,user:Sir Duncan
Wed, 25 May 2011 14:54:08 +0200|a giant worm governs Underworld|http://www.underworld-game.net/|There is a new King in Underworld:\n<a href="http://www.underworld-game.net/infobox
As it stands, the journal file is not a standard RSS file. The management of the text and of RSS format would slow down the execution of the dimensioneX server and therefore it has been designed to be done externally.
Then, the game developer must implement its own Journal-to-RSS feed converter, possibly on the game’s official website.
On the DimensioneX website, Downloads section, we provide a free, Open Source, Journal-To-RSS converter which works in real time written in PHP which is perfect for general use.
The Journal file is tied to the game’s Cluster (see also: 1.2.11 – Multi-Area support (Clustering)) and can be configured inside the worldnav.properties of any of the cluster’s worlds (see also: 1.3.3 – Game Settings).
We recommend to generate the Journal file in a folder that’s accessible from the web. In the above example, the journal.txt file is generated so that it can be accessed by http://localhost:8080/dimx/journal.txt in a standard development environment. You should adapt this logic to your own case.
See a working implementation of this system on our Underworld Online game, running on DimensioneX, at http://www.underworld-game.net . The journal file is generated in a public folder of our dimensionex game server play.dimensionex.net (we will not disclose the exact URL, but it’s not important) then the official website fetches it and turns it into a standard RSS feed in real time. Free services such as RSS Graffiti and TwitterFeed will pipe these RSS content to the game’s Twitter channel and the game’s Facebook page.