How to use a RoomExtension
Posted: 06 Jul 2012, 15:34
Hello,
I create a lot of rooms when sfs2x started and also create RoomExtension for each room.
Everything works fine. I can see on the admin panel everything is ok. But I have some problems.
When I send an event for a roomExtension, an error occurred. The error is :
addRequestHandler is in RoomExtension init function.
Normally RoomExtension extends SFSExtension or SFSBaseExtension.
That means I can add the addRequestHandler in a RoomExtension, but it doenst works. Why doesnt works it?
My second problem is about sfs roomExtensions performance. I create 70 rooms, when server started. Each room has an roomExtension. And each extension works with Thread and some runnable functions. I think that is a serious performance loss. I dont know, maybe I think wrong. Which method is best for that scenario?
I create a lot of rooms when sfs2x started and also create RoomExtension for each room.
Everything works fine. I can see on the admin panel everything is ok. But I have some problems.
When I send an event for a roomExtension, an error occurred. The error is :
Code: Select all
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Request handler not found: 'GAME EVENT'. Make sure the handler is registered in your extension using addRequestHandler()
Description: Error while handling client request in extension: { Ext: Games, Type: JAVA, Lev: ZONE, { Zone: Ball}, {} }
Extension Cmd: GAME EVENT
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:181)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:137)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
addRequestHandler is in RoomExtension init function.
Code: Select all
public class RoomExtension extends SFSExtension{
@Override
public void init() {
addRequestHandler(CustomEventType.GAME_EVENT, GameController.class);
}
}
Normally RoomExtension extends SFSExtension or SFSBaseExtension.
That means I can add the addRequestHandler in a RoomExtension, but it doenst works. Why doesnt works it?
My second problem is about sfs roomExtensions performance. I create 70 rooms, when server started. Each room has an roomExtension. And each extension works with Thread and some runnable functions. I think that is a serious performance loss. I dont know, maybe I think wrong. Which method is best for that scenario?