Java Extensions Problems
Posted: 02 Apr 2011, 12:57
Hi, first of all my compliments for this kind of server which i found very useful for developing a project and saved me a lot of time.
My problem is that I read the tutorial and i still couldn't understand how to use java extensions.
I mean:
I wrote a simple java extension following this template:
I compiled it and as said in the tutorial i put the .class file in the javaExtensions folder (i also tried putting the class and its package folders).
Then i opened the config.xml file and i added in a room this piece of XML:
Then i started the server but it said that my extension cannot be found in the sfsExtensions folder.
If i try to put my class in that folder the server finds it but it gives me an error about a wrong character at line xxx.
So, of course i'm missing something and i ask you if you can give me some simple instructions to make this extension work.
Thank you!
My problem is that I read the tutorial and i still couldn't understand how to use java extensions.
I mean:
I wrote a simple java extension following this template:
Code: Select all
import it.gotoandplay.smartfoxserver.data.*;
import it.gotoandplay.smartfoxserver.extensions.*;
import it.gotoandplay.smartfoxserver.lib.ActionscriptObject;
import it.gotoandplay.smartfoxserver.events.InternalEventObject;
import org.json.JSONObject;
public class ExtensionTemplate extends AbstractExtension
{
public void init()
{
//Initialization
}
public void destroy()
{
//Called when the extension is destroyed
}
public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
{
// Your code here, handles XML-based requests
}
public void handleRequest(String cmd, JSONObject jso, User u, int fromRoom)
{
// Your code here, handles JSON-based requests
}
public void handleRequest(String cmd, String params[], User u, int fromRoom)
{
// Your code here, handles String-based requests
}
public void handleInternalEvent(InternalEventObject ieo)
{
// Your code here, handles server events
}
public Object handleInternalRequest(Object param)
{
// (Optional) Your code here, handles an internal request
return param;
}
}
Then i opened the config.xml file and i added in a room this piece of XML:
Code: Select all
<Extensions>
<extension name="ExtensionTemplate" className="ExtensionTemplate.class" type="script" />
</Extensions>
If i try to put my class in that folder the server finds it but it gives me an error about a wrong character at line xxx.
So, of course i'm missing something and i ask you if you can give me some simple instructions to make this extension work.
Thank you!