Get Sender on custom extension response

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
helto
Posts: 6
Joined: 28 Oct 2008, 21:52
Contact:

Get Sender on custom extension response

Post 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?
itsmylifesoham
Posts: 186
Joined: 16 Oct 2011, 14:33

Re: Get Sender on custom extension response

Post 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?
secret007
Posts: 58
Joined: 29 May 2009, 06:27

Re: Get Sender on custom extension response

Post 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);

}
======================================================
Choose a job of your choice and you will never have to work in life !!!
helto
Posts: 6
Joined: 28 Oct 2008, 21:52
Contact:

Re: Get Sender on custom extension response

Post 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
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Get Sender on custom extension response

Post 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 ;)
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.
secret007
Posts: 58
Joined: 29 May 2009, 06:27

Re: Get Sender on custom extension response

Post 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 :)
======================================================
Choose a job of your choice and you will never have to work in life !!!
Post Reply