I´m trying to write my first Extension right now. It is a Room Level Extension.
I successfully managed to register a request handler, and now I´m trying to implement an EventHandler, to listen to USER_VARIABLES_UPDATE events, but no luck so far.
The listener is registered in the following way:
addEventHandler( SFSEventType.USER_VARIABLES_UPDATE , UserVariableUpdateEventHandler.class );
The handleServerEvent method of the UserVariableUpdateEventHandler class just traces some text right now, but it never seems to be invoked. I have a client connected and joined in the room, who changes his user variable with a SetUserVariablesRequest. This request seems to have success, because the client catches a SFSEvent.USER_VARIABLES_UPDATE event.
How can I find out why the Extension doesn´t handle this event? Or are room level extensions for some reason not able to catch Variables Updates events?
Thanks for any help.
Room Extension and USER_VARIABLES_UPDATE Events
Just did some more testing: The extension does catch SFSEventType.USER_JOIN_ROOM type events without a problem.
I would guess that no SFSEventType.USER_VARIABLES_UPDATE events are fired in the room at all, but the client catches them without a problem.
Tested this both on RC1A and RC1B, no difference.
I would guess that no SFSEventType.USER_VARIABLES_UPDATE events are fired in the room at all, but the client catches them without a problem.
Tested this both on RC1A and RC1B, no difference.
Hi,
the event is not dispatched at Room Level because it is beyond the scope of the Room.
Example:
UserA joins the Zone and goes into Room1
UserB joins the Zone and sets a new UserVariable, called "avatar"
Should the extension in Room1 get the event? NO, because it is irrelevant to the Room.
Probably it should be notified if the User setting the variable was also joined in that Room, however at the moment it is not implemented this way. So if you want to listen for UserVariables changes you should use a Zone Level Extension.
Hope it helps
the event is not dispatched at Room Level because it is beyond the scope of the Room.
Example:
UserA joins the Zone and goes into Room1
UserB joins the Zone and sets a new UserVariable, called "avatar"
Should the extension in Room1 get the event? NO, because it is irrelevant to the Room.
Probably it should be notified if the User setting the variable was also joined in that Room, however at the moment it is not implemented this way. So if you want to listen for UserVariables changes you should use a Zone Level Extension.
Hope it helps
Yes, under the SFSEventType class:
http://docs2x.smartfoxserver.com/api-do ... tType.html
http://docs2x.smartfoxserver.com/api-do ... tType.html
Re: Room Extension and USER_VARIABLES_UPDATE Events
Its helpful to know that something that is not happening as expected shouldn't happen by design, but I have to say not providing a means to allow Room extensions to receive user variable updates without creating an event system with a Zone extension is weak. This effectively renders User Variables almost useless within a room extension. I followed the documentation's recommendation to use Zone ex as login and create a room extension to manage the room.
What do you recommend to people who want to respond to user variable updates at the room level? The standing advice of "You can't" isn't a recommendation on how to deal with the feature absence. I am truly looking for a recommendation such as "it would be easy to catch the events at the zone level and send them to the room extension if you XYZ".
Your help is much appreciated. Thank you!
What do you recommend to people who want to respond to user variable updates at the room level? The standing advice of "You can't" isn't a recommendation on how to deal with the feature absence. I am truly looking for a recommendation such as "it would be easy to catch the events at the zone level and send them to the room extension if you XYZ".
Your help is much appreciated. Thank you!
Last edited by ktamlyn on 05 Sep 2013, 18:01, edited 2 times in total.
Re: Room Extension and USER_VARIABLES_UPDATE Events
Also, the link is broken now.
Re: Room Extension and USER_VARIABLES_UPDATE Events
"it would be easy to catch the events at the zone level and send them to the room extension if you XYZ".
Yes it is easy to do
1) Catch the event at the Zone Level.
2) Call --> theRoom.getExtension().handleInternalMessage(event)
(where theRoom is your target Room and event is the whole event object)
That's all
Re: Room Extension and USER_VARIABLES_UPDATE Events
Thanks!
Next question, related. If I use a room variable instead of a User Variable, when do I know that events will fire?
For example using the following code doesn't result in any user getting an update event:
Am I forced into something similar to:
Next question, related. If I use a room variable instead of a User Variable, when do I know that events will fire?
For example using the following code doesn't result in any user getting an update event:
Code: Select all
RoomVariable rv = new SFSRoomVariable(RoomVariables.ALL_PARTICIPANTS_READY, false);
rv.setGlobal(true);
try {
room.setVariable(rv);
} catch (SFSVariableException e) {
e.printStackTrace();
}
Am I forced into something similar to:
Code: Select all
RoomVariable rv = new SFSRoomVariable(RoomVariables.ALL_PARTICIPANTS_READY, true);
rv.setGlobal(true);
List<RoomVariable> listOfVars = Arrays.asList(rv);
parentEx.getApi().setRoomVariables(sessionBean.getFacilitator().getSFSUser(), room, listOfVars, true, false, true);
Re: Room Extension and USER_VARIABLES_UPDATE Events
Yes you are "forced" to use the server side API As we recommend in our documentation:
http://docs2x.smartfoxserver.com/Develo ... ension-api
The first code example is incorrect because it will only create the Room Variable but won't trigger any client update
http://docs2x.smartfoxserver.com/Develo ... ension-api
The first code example is incorrect because it will only create the Room Variable but won't trigger any client update
Re: Room Extension and USER_VARIABLES_UPDATE Events
Update smart fox server version 2.9.0. In my Room level Extension I have this:
When changing a variable
var someVariable: UserVariable = new SFSUserVariable ("value", value);
sfs.send (new SetUserVariablesRequest ([someVariable]));
Extention log in the console have the following:
TWICE ..?
some variable change
some variable change
Why is called two times?
Code: Select all
this.addEventHandler (SFSEventType.USER_VARIABLES_UPDATE, OnUserVariableUpdate.class);
/////////////
public class OnUserVariableUpdate extends BaseServerEventHandler
{
Override
public void handleServerEvent (ISFSEvent event) throws SFSException
{
trace ("some variable change");
}
}
When changing a variable
var someVariable: UserVariable = new SFSUserVariable ("value", value);
sfs.send (new SetUserVariablesRequest ([someVariable]));
Extention log in the console have the following:
TWICE ..?
some variable change
some variable change
Why is called two times?
Re: Room Extension and USER_VARIABLES_UPDATE Events
Are you sure you don't have some other code running somewhere else?
Maybe the same Extension is attached in two places? Like two different Zones? Or a Zone and a Room?
I ask because if I do the same I get one event which tells me that something else is the problem.
thanks
Maybe the same Extension is attached in two places? Like two different Zones? Or a Zone and a Room?
I ask because if I do the same I get one event which tells me that something else is the problem.
thanks
Re: Room Extension and USER_VARIABLES_UPDATE Events
I do not think so, in Action Script code everything is fine there trace once. Any ideas why room extension траце 2 times?
Re: Room Extension and USER_VARIABLES_UPDATE Events
But we're talking about server side, not client side.
The only reason why you see the message twice is that you have two listeners for that event on the server side.
Can you double check the Extension is not running in multiple places or, more generally, that you don't have other listeners for that same event in the system?
Other options is that you might be running a very very old version of the server, although we have never heard of such problem even with the earliest release.
The only reason why you see the message twice is that you have two listeners for that event on the server side.
Can you double check the Extension is not running in multiple places or, more generally, that you don't have other listeners for that same event in the system?
Other options is that you might be running a very very old version of the server, although we have never heard of such problem even with the earliest release.
Re: Room Extension and USER_VARIABLES_UPDATE Events
For the moment I have a listener for user variable update which is located in Room Extension. But I'm going to do 10 rooms in all to put this listener. From your answer I understand that this will destroy the system. In this case, the solution is to put a listener in Zone Extension and when poss to receive communications, room extensions. Then we use handleInternalMessage. Would that be correct.
Who is online
Users browsing this forum: Google [Bot] and 110 guests