Sending extension response from handler outside

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

freeandoni
Posts: 14
Joined: 28 Feb 2012, 19:02

Sending extension response from handler outside

Postby freeandoni » 28 Feb 2012, 19:08

Hello,

I'm using a thread outside BaseClientHandler and I want to send a extension request from there.

Is there a way?

I have tried with this but I'm not receiving the response on the client:

Code: Select all

       
        APIManager api = new APIManager();
        api.getSFSApi().sendExtensionResponse("POSITION_UPDATE_RESPONSE", sfsobject, user, user.getLastJoinedRoom(), false);


I'm not sure if this the correct way.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Sending extension response from handler outside

Postby rjgtav » 28 Feb 2012, 23:48

Hi.
No, you're creating a new APIManager, of course it won't work. You have to use the one that SFS uses.
If your handler extends the BaseClientRequestHandler class, then you can simply do:

Code: Select all

send("POSITION_UPDATE_RESPONSE", sfsobject, user, user.getLastJoinedRoom(), false);
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
freeandoni
Posts: 14
Joined: 28 Feb 2012, 19:02

Re: Sending extension response from handler outside

Postby freeandoni » 01 Mar 2012, 11:38

finally I used this:

Code: Select all

SmartFoxServer.getInstance().getAPIManager().getSFSApi().sendExtensionResponse(name,data,user,room,false);

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 14 guests