Simple Extension doesn't show up in the admin

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

Moderators: Lapo, Bax

Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Simple Extension doesn't show up in the admin

Postby Angélique » 11 Jul 2011, 21:11

Hello there,

I am currently trying SmartFoxServer to see if it would be a suitable solution for our multiplayer games project.

I find it a bit hard to get the right documentation, though.

I'm trying to make an extension, but it can't get it to show up in the server admin.
The jar file is under "{SERVER}/extensions/test/" folder, and the jar file is named "TestExtension.jar".

There's almost no code in the java class, it's a very simple one based on the simple chat tutorial.

I'm new to JAVA (come from Ruby and ActionScript 3) so I wonder if the problem could be from an error in my java classes. I use Eclipse and JAVA 1.6.

What could be the problem ?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 11 Jul 2011, 21:36

Hi,

this is my zone extension file :

Code: Select all

package net.edje.projects.SFS2xBase;

import com.smartfoxserver.v2.core.SFSEventType;
import com.smartfoxserver.v2.extensions.SFSExtension;

public class ZoneExtension extends SFSExtension {

    @Override
    public void init() {
        addEventHandler(SFSEventType.USER_JOIN_ZONE, JoinZoneHandler.class);
    }
}


Thats basicly all that it needs.[/code]
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 11 Jul 2011, 23:11

Ok... I'm not sure this is my problem then, because mine is quite close :

Code: Select all

package com.bigroundeyes.java.spawn;

import com.smartfoxserver.v2.extensions.SFSExtension;

public class SpawnExtension extends SFSExtension {

   @Override
   public void init() {
      addRequestHandler("PLAY", Game.class);

   }

}


In Eclipse, I use export, and export a jar file to the extensions folder of SFS.
Still, the file doesn't show up in the admin.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 11 Jul 2011, 23:45

Did you compile the jar with Source binary format JDK 6 ?
I use Netbeans and thats the only thing i had to modify.
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 12 Jul 2011, 00:03

I don't really know... I'm not familiar with JAVA.
When I try to check in my project properties, and "JAVA compiler", it says JavaSE-1.6.

I don't really see any other place to set up this.

To get the jar file, I'm doing like in the SFSx2 tutorial video : I'm using the export feature. It takes no time to do it and it doesn't confirm the compilation was ok, so I don't know if it's all right, though the file is created... I just checked actually, and the jar file is only 3Ko. There should be 2 classes in the project, so 3Ko seems definitely small, even for small classes isn't it ?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 00:10

hard to tell but i just checked on my smallest jar and it's 12K and has 2 files in it
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 12 Jul 2011, 00:17

hm.. is this normal that my jar file is just a sort of zip I can extract and get the class file ? I looks like it zips it, but doesn't really compile anything... ?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 00:21

yes, you can open it and extract the files but i think it will be garbled text in the files
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 00:25

just stumbled upon this :

Start Eclipse and make sure the JRE is pointing to the JAVA 6 JRE. (Window->Preferences->Java->Installed JRE's)
In Eclipse preferences (Window->Preferences->Java->Compiler), set the compliance level to '6.0'.

It's from another site but it should apply for SFS
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 12 Jul 2011, 01:07

First, thank you so much for your help.

I checked my config. The installed jre is ok.
I have a doubt for the compiler. You say "6.0" but all I can select is 1.6 or previous version. It seems to use something called JavaSE-1.6. Is it different from the SDK ?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 01:17

I'm no expert but yes i think you need to have the SDK, if i recall right.
Also check this topic on extensions, might have more info on it :
http://www.smartfoxserver.com/forums/viewtopic.php?t=8107

It's the JDK 6.0
http://www.oracle.com/technetwork/java/javase/downloads/index.html
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 12 Jul 2011, 09:01

@Angélique, did you check the logs for possible errors when starting SFS, or when you access the extension setup tab in the AdminTool?
Paolo Bax
The SmartFoxServer Team
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 12 Jul 2011, 14:44

Thank you so much both of you.

Indeed, I finally found there was some errors thrown in the server log.
I fixed my package name and now the code is working : my Actionscript 3 client can connect and log to this zone.
Thank you again, appels and bax.

Though, the extensions still don't show up when I create or modify a zone in the 'Extension Zone' tab. The 'Start Extension file monitor' in the Server config seems to be on (the radio button is green).
It's not absolutely necessary since now the extension works, at least. But it would be nice to understand why the auto detection of the zone extension don't work for me.
Do you have any idea ?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 14:58

the extension won't show in the admin tool if the name doesn't end in ...Extension.jar.
Thats a fault i had at start, as soon as i changed the filename it popped up in the tool.
Thats all i can think off.
Angélique
Posts: 10
Joined: 11 Jul 2011, 20:58

Postby Angélique » 12 Jul 2011, 15:11

My file is called SpawnExtension.jar

But actually no extension shows up, even three example from Smartfox Server. :(

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 41 guests