SFSEventType USER_DISCONNECT
SFSEventType USER_DISCONNECT
when USER_DISCONNECT event is called, this custom handler-- zone and room . why zone handler first ,then room handler ? can change the order of these two ? thx
Zone events are usually fired first, because the Zone has control over the Rooms not the other way around.
And no it's not possible to change it.
BTW: there should be no dependency between events in a Zone and its Rooms, if so you might consider rethinking your code to avoid that.
Events are asynchronous and wanting to synchronize them via code dependencies is not a good a idea. My 2C
And no it's not possible to change it.
BTW: there should be no dependency between events in a Zone and its Rooms, if so you might consider rethinking your code to avoid that.
Events are asynchronous and wanting to synchronize them via code dependencies is not a good a idea. My 2C
SFSEventType USER_DISCONNECT
thanks a lot,Lapo.I see it now.Lapo wrote:Zone events are usually fired first, because the Zone has control over the Rooms not the other way around.
And no it's not possible to change it.
BTW: there should be no dependency between events in a Zone and its Rooms, if so you might consider rethinking your code to avoid that.
Events are asynchronous and wanting to synchronize them via code dependencies is not a good a idea. My 2C
I have another question:when users leave the sfs2x server,and i will save user's info to database,but I don't kown how and when to do it! beacause,server trigger these events ,maybe USER_LOGOUT,USER_LEAVE_ROOM,or USER_DISCONNECT...
i Confused。
Many thanks for your help and i look forward to your reply.
SFSEventType USER_DISCONNECT
when gaming is running if user close browser the room,what will happend?
Event USER_LEAVE_ROOM must can be called?
and after then call USER_DISCONNECT event?
thx
Event USER_LEAVE_ROOM must can be called?
and after then call USER_DISCONNECT event?
thx
SFSEventType USER_DISCONNECT
hi Lapo ,yes i'm talking about server side event.Lapo wrote:Are you talking about server side events?
You will get the disconnection event. On the client nothing
I wrote some codes like these.
/**
* a Room-level Extension can only listen to the events in that Room and manage
* the Users contained in it. A typical use of Room-level Extension is to manage
* the logic of a game running in the Room.
*/
public class GameExtention extends SFSExtension {
....
init(){
....
addEventHandler(SFSEventType.USER_LEAVE_ROOM,
UserLeaveRoomHandler.class);
addEventHandler(SFSEventType.USER_DISCONNECT,
UserDisconnectHandler.class);
....
}
}
/**
* A Zone-level Extension can listen to any event in the Zone and control all
* the Rooms and Users in that it manages.
*/
public class AppExtension extends SFSExtension {
............
init(){
..........
addEventHandler(SFSEventType.USER_DISCONNECT,
UserDisconnectHandler.class);
.............
}
..........
}
now,when SFSEventType.USER_DISCONNECT event called,
UserDisconnectHandler be invoked twice.
public class UserDisconnectHandler extends BaseServerEventHandler {
....................
handleServerEvent(ISFSEvent event(){
....
saveUserInfo();//save user's data to database...
....
}
................
}
and so same code in UserLeaveRoomHandler.
where should i save user's data to database,and how?
because ,if user left in room ,game status changed,and some data.
it different from in zone....logic.
thx
SFSEventType USER_DISCONNECT
Lapo wrote:As I said, and you can check the docs for all the details, you get the DISCONNECT event. The event will then give you all the details about which rooms the User had joined etc...
OK,some questions is ,
1) when SFSEventType.USER_LOGOUT event was called, SFSEventType.USER_DISCONNECT event must be called?
2) in zone level , i can get DISCONNECT event and kown which rooms the User had joined,how i can get the room-level Extension? my game logic in the room Extension.
thank you very much for your help.
1) No, logout simply means you leave the current zone but you don't drop the connection
2) Check the javadoc, a Room object exposes a getExtension() method
http://docs2x.smartfoxserver.com/api-do ... oc/server/
2) Check the javadoc, a Room object exposes a getExtension() method
http://docs2x.smartfoxserver.com/api-do ... oc/server/
SFSEventType USER_DISCONNECT
Lapo wrote:1) No, logout simply means you leave the current zone but you don't drop the connection
2) Check the javadoc, a Room object exposes a getExtension() method
http://docs2x.smartfoxserver.com/api-do ... oc/server/
OK,I see it now.
Lapo,thank you!