Page 1 of 1

Get Sender on custom extension response

Posted: 21 Mar 2012, 01:20
by helto
I'm building some custom extensions where I need to know which user sent the request. Do I have to return the sender from Java with every extension that needs this or is there a way to get this already?

Re: Get Sender on custom extension response

Posted: 21 Mar 2012, 05:53
by itsmylifesoham
hi,

you must be having some client request handler defined for the incoming client request in you extension right?
in this handler which basically extends baseclientrequesthandler you can write

Code: Select all

User sender = (SFSUser) event.getParam(sfseventparam.USER) ;
so you can get the user who sent the request...is this what you wanted or something else?

Re: Get Sender on custom extension response

Posted: 21 Mar 2012, 06:52
by secret007
i think you have to pass sender through sfsobject in the send command like so,

Code: Select all

public void handleClientRequest(User sender, ISFSObject params)
{
    sfsObject.putfString("who invokes this", sender.getName());
    send("Hello", sfsObject,  getRoom.userList);

}

Re: Get Sender on custom extension response

Posted: 21 Mar 2012, 11:50
by helto
Thanks secret, that's what I'm doing now. Just wondered if I had to return that myself. I'll probably make an abstract class that sends that by default

Re: Get Sender on custom extension response

Posted: 21 Mar 2012, 18:51
by rjgtav
Hello.
I didn't understand your problem quite well... So you want to send an extension message to every user on a room and tell them who previously sent an extension request right? If that's the case, so yeah, you have to manually add the sender's name to the response SFSObject. In case that sender is always on the same room as the receivers, you can just send his userId, and save some important bandwidth ;)

Re: Get Sender on custom extension response

Posted: 23 Mar 2012, 06:40
by secret007
helto wrote:Thanks secret, that's what I'm doing now. Just wondered if I had to return that myself. I'll probably make an abstract class that sends that by default
you welcome :)