I want to simple test how the extension work.
I have been how to make the extension .as file but I cannot see anywhere on on any documentation how to add the extension to any zone or room.
Code: Select all
function init() {
//This is called when the extension loads (when the server first starts).
trace("Simple extension is starting.");
}
function destroy() {
//This is called when the extension is destroyed.
trace("Simple extension is ending.");
}
function handleRequest(cmd, params, user, fromRoom) {
trace("Working...")
var responseObj = {}
responseObj._cmd = "status"
responseObj.name = "server"
_server.sendResponse(responseObj, -1, null, user)
}
function handleInternalEvent(e) {
//This is called when any internal event is executed.
trace("Internal event: " + e.name + " was called."); //Traces the internal event that was executed.
}
But now is the question how to add this extension to smartfoxserver.
I see how to add java extensions in the configuration file for zones in zones folder.
Code: Select all
<extension>
<name>sfsTris</name>
<type>JAVA</type>
<file>sfs2x.extensions.games.tris.SFSTrisGame</file>
<propertiesFile></propertiesFile>
<reloadMode>AUTO</reloadMode>
</extension>
But how should I figure out what the value is for AS file?
I tried...
Code: Select all
<extension>
<name>simpleExtTut</name>
<type>SCRIPT</type>
<file>simpleExtTut.as</file>
<propertiesFile></propertiesFile>
<reloadMode>AUTO</reloadMode>
</extension>
But this throws error:
Code: Select all
07 Aug 2011 15:05:21,485 INFO [main] v2.config.SFSConfigurator - Loading: zones/SimpleChat.zone.xml
07 Aug 2011 15:05:21,525 ERROR [main] smartfoxserver.v2.SmartFoxServer -
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$DuplicateFieldException
Message: extension
---- Debugging information ----
duplicate-field : extension
class : com.smartfoxserver.v2.config.ZoneSettings
required-type : com.smartfoxserver.v2.config.ZoneSettings
path : /zone/extension[2]
I just need this simple extension to work
Thanks.
I also tried.
Code: Select all
<roomVariables/>
<Extensions>
<extension name="simpleExtTut" className="simpleExtTut.as" type="script" />
</Extensions>
</room>