@MultiHandler

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

Moderators: Lapo, Bax

Post Reply
dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

@MultiHandler

Post by dingo »

Hi there

if i follow the code from the tutorial:

Code: Select all

@MultiHandler
public class RegisterMultiHandler implements IClientRequestHandler 
{ 
    @Override
    public void handleClientRequest(User sender, ISFSObject params, SFSExtension parentExt) 
    { 
        // Obtain the request id 
        String requestId = params.getUtfString(SFSExtension.MULTIHANDLER_REQUEST_ID); 
    } 
} 
I get the error message that i need in Override getParentExtension().
If i override it, i get this:

Code: Select all

@Override
    public SFSExtension getParentExtension() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
In these examples http://forums.smartfoxserver.com/viewto ... ltihandler the class extends BaseClientRequestHandler instead of implementing IClientRequestHandler.

Is there an error in the documentation?

Many thanks.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

You need to extend a class called BaseClientRequestHandler
Check the docs here:
http://docs2x.smartfoxserver.com/Advanc ... extensions
see the snippets of code in the middle of the article.
Lapo
--
gotoAndPlay()
...addicted to flash games
dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

Post by dingo »

great, got it working, thanks.

But then I think your docs have a mistake further down where it says:
The Extension API provide a @MultiHandler annotation
Because there the example implements IClientRequestHandler instead of extending BaseClientRequestHandler
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

sure, thank you
Lapo
--
gotoAndPlay()
...addicted to flash games
milosh6
Posts: 27
Joined: 06 Sep 2006, 14:09

Post by milosh6 »

Hello there,

long time no see, Lapo :) Back to SmartFox server and I see you did a wonderful job with version 2X. I am amazed.

However... I also have problem with this MultiHandler. Implemented the new corrected way. These are my code cutouts:

The zone extension

Code: Select all

public class MyExt extends SFSExtension
{
    @Override
    public void init()
    {
         initialize();
    }

    private void initialize()
    {
         addRequestHandler("Unit", UnitHandler.class);
    }
}
The "UnitHandler"

Code: Select all

@MultiHandler
@Instantiation(InstantiationMode.SINGLE_INSTANCE)
public class UnitHandler extends BaseClientRequestHandler
{  
    @Override
    public void handleClientRequest(User sender, ISFSObject params)
    {
         String requestId = params.getUtfString(SFSExtension.MULTIHANDLER_REQUEST_ID);
    }	
}
And the error message I get:
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Request handler not found: 'Unit.Move.Stop'. Make sure the handler is registered in your extension using addRequestHandler()
milosh6
Posts: 27
Joined: 06 Sep 2006, 14:09

Found the problem

Post by milosh6 »

OK... so althought at first I did not know what else to try, I figure it only works for one level of dot. Thus register a request to "Unit" works only for Unit.* but not for Unit.*.*... OK, this was not clearly mentioned in the http://docs2x.smartfoxserver.com/Advanc ... extensions article.
Post Reply