Server event handler not invoked

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

Moderators: Lapo, Bax

pgbrandao
Posts: 8
Joined: 26 Nov 2010, 16:34

Server event handler not invoked

Postby pgbrandao » 05 May 2011, 16:23

Hi everyone!

This is a strange bug, since it happens on my test server but not on my local machine, but here goes... The problem is that my custom login event handler isn't being called. I'm adding it to the extension like this:

Code: Select all

addEventHandler(SFSEventType.USER_JOIN_ZONE, OnUserJoinHandler.class);


And the OnUserJoinHandler class is like this:

Code: Select all

public class OnUserJoinHandler extends BaseServerEventHandler {

   @Override
   public void handleServerEvent(ISFSEvent event) throws SFSException {
      User user = (User) event.getParameter(SFSEventParam.USER);
      
      (...)

   }

}


As soon as the user is logged in, though, this is the error I get:

Code: Select all

17:11:17,506 INFO  [pool-1-thread-2] api.SFSApi     - Login in, { Zone: SuperArena }, ( User Name: pgb, Id: 0, Priv: 0, Sess: 10.8.0.6:51126 )
java.lang.ClassCastException: com.smartfoxserver.v2.core.SFSEvent cannot be cast to com.smartfoxserver.v2.core.SFSSystemEvent
   at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:792)
   at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:687)
   at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:883)
   at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:64)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
17:11:17,526 WARN  [pool-1-thread-2] core.SFSEventManager$SFSEventRunner     - Error in event handler: java.lang.ClassCastException: com.smartfoxserver.v2.core.SFSEvent cannot be cast to com.smartfoxserver.v2.core.SFSSystemEvent, Event: { USER_JOIN_ZONE, Params: [USER, ZONE] } Listener: com.smartfoxserver.v2.entities.managers.SFSExtensionManager@2792c07a


Can anyone point me in the right direction? I'd be very grateful...

Thanks!
Pedro.
tchen
Posts: 191
Joined: 11 Dec 2010, 14:14

Postby tchen » 05 May 2011, 18:20

I'd hazard a guess that its a patch mis-match issue. Are you sure you're compiling against the same version as the server for both machines?

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 61 guests