simple actionscript extension

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

hw2002
Posts: 6
Joined: 06 Aug 2011, 10:28

simple actionscript extension

Postby hw2002 » 07 Aug 2011, 12:01

Hello,

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>
hw2002
Posts: 6
Joined: 06 Aug 2011, 10:28

Postby hw2002 » 07 Aug 2011, 14:29

This doesn't throw any errors in the log when running the server..

Code: Select all

<extension>
       <name>simple</name>
       <type>JAVASCRIPT</type>
       <file>simpleExt.as</file>
       <propertiesFile></propertiesFile>
       <reloadMode>AUTO</reloadMode>
     </extension>


But I get error when I want to use the extension while the server is running:

Code: Select all

07 Aug 2011 17:31:47,315 INFO  [com.smartfoxserver.v2.controllers.SystemController-1] v2.api.SFSApi     - Login in, { Zone: SimpleChat }, ( User Name: ggffg, Id: 1, Priv: 0, Sess: 127.0.0.1:60963 )
07 Aug 2011 17:31:47,394 INFO  [com.smartfoxserver.v2.controllers.SystemController-1] v2.controllers.SystemController     - {IN}: JoinRoom
07 Aug 2011 17:31:47,459 WARN  [com.smartfoxserver.v2.controllers.ExtensionController-1] v2.controllers.ExtensionController     -
com.smartfoxserver.v2.exceptions.SFSExtensionException: No extensions can be invoked: { Zone: SimpleChat }, RoomId: 1
   com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:120)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   java.lang.Thread.run(Thread.java:680)
Sarevok
Posts: 75
Joined: 12 Apr 2011, 22:12

Postby Sarevok » 08 Aug 2011, 06:55

What server version do you use?
I can't recognize the way you are trying to configure your config.xml file, and I don't remember any zones folder. Is that smartfox 2 maybe? Because this is smartfox 1.x subforum.

This is example how to change config file in smartfox 1.x (I assume your file is simpleExtTut.as):

Code: Select all

<Zones>   
   
      <Zone name="simpleChat" uCountUpdate="true" buddyList="20" maxUsers="4000" customLogin="false">
         <Rooms>
            <Room name="The Hall" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="true" />      
            <Room name="The Kitchen" maxUsers="50" isPrivate="false" isGame="false" isTemp="false" />
            
         </Rooms>
         
         <Extensions>
            <extension name="simpleExtTut" className="simpleExtTut.as" type="script" />
         </Extensions>         
      </Zone>
</Zones>


If you use smartfox 2x then you should know that it does not support actionscript extension. Only java extensions are possible :)
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 09 Aug 2011, 23:56

Moved to an more appropriate place.
Smartfox's forum is my daily newspaper.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 44 guests