Page 1 of 1

@MultiHandler

Posted: 11 Jan 2011, 13:41
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.

Posted: 11 Jan 2011, 14:53
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.

Posted: 12 Jan 2011, 05:41
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

Posted: 12 Jan 2011, 08:05
by Lapo
sure, thank you

Posted: 08 Feb 2011, 11:53
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()

Found the problem

Posted: 08 Feb 2011, 12:07
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.