Server modules

From PhiWiki
Revision as of 14:19, 6 March 2014 by Schumi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Since v1.5.0 the server component of Phi can be extended with modules (or runtime plug-ins) written in C++. Phi offers a straight forward C++ API to create global JavaScript objects for Serverscript.pngServerScript.

Using modules

Distributed modules

The following Serverscript.pngServerScript classes existed already in previous versions of Phi but could not be extended or changed programmatically. Now they are implemented as exchangeable modules accessible as a runtime plug-in:

Loading a module

To load a specific module enter the following code in the top of your Serverscript.pngServerScript file:



system.log('log something to the server error log');

Item API

Since v1.5.0 Phi offers the item API (probably already known from the client environment) also in Serverscript.pngServerScript.

Since v2.0.0 this should be the only used interface to access items and is now an integral part of the server.

loadModule('wrapper'); // needed before v2.0.0 only!

Creating modules

Since v1.5.0 you can create your own modules through a C++ module API to provide JavaScript objects for Serverscript.pngServerScript. This might be of interest for module programmers only or if you have special business needs.