Pass extra params in server EventHandler

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

Moderators: Lapo, Bax

User avatar
moccha
Posts: 112
Joined: 13 Feb 2014, 16:09

Pass extra params in server EventHandler

Postby moccha » 06 Dec 2021, 16:18

Hi,

Is it possible to pass additional parameters from the server to the client when firing certain events? For example, is it possible to pass extra variables when a USER_JOIN_ROOM request is handled serverside?

Server:

Code: Select all

this.addEventHandler(SFSEventType.USER_JOIN_ROOM, JoinRoomHandler.class);


and within JoinRoomHandler.class:

Code: Select all

public class JoinRoomHandler extends BaseServerEventHandler
{
    @Override
    public void handleServerEvent(ISFSEvent event) throws SFSException
    {   
        // Get event param
        SFSRoom room = (SFSRoom) event.getParameter(SFSEventParam.ROOM);
       
        // Pass extra data to process clientside SFSEvent event
        ...
    }
}


I want to send a few extra variables to the client (from server) when another user joins their room.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Pass extra params in server EventHandler

Postby Lapo » 06 Dec 2021, 17:56

Hi,
sorry it's not possible. The server-side events are not linked to the client side ones, in fact they travel in separate threads. Also when the server triggers the USER_JOIN_ROOM event, the relative client has already been sent out.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
moccha
Posts: 112
Joined: 13 Feb 2014, 16:09

Re: Pass extra params in server EventHandler

Postby moccha » 06 Dec 2021, 18:27

OK, I will look to sending another update within USER_JOIN_ROOM then.

Thanks for the info Lapo.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 136 guests