I am trying to maintain a state on the server for every player in the room, using a room extension that keeps a variable if the player is connected or disconnected. So is there any way to check from the server-side that if any player has disconnected, so I can update that variable accordingly?
I am new to the smartfox, so i apologize if this is a basic question.
Disconnection Check from server side
Re: Disconnection Check from server side
Hi,
in your extension you can listen for a number of server-side events such as a User disconnection.
If you're not familiar with server-side event, just check the introductory tutorial on Extensions here:
http://docs2x.smartfoxserver.com/Extens ... uick-start
It shows an example of how to set an event listener.
The parameters passed by each server-side events are documented in the SFSEventType class in our javadoc.
Cheers
in your extension you can listen for a number of server-side events such as a User disconnection.
If you're not familiar with server-side event, just check the introductory tutorial on Extensions here:
http://docs2x.smartfoxserver.com/Extens ... uick-start
It shows an example of how to set an event listener.
The parameters passed by each server-side events are documented in the SFSEventType class in our javadoc.
Cheers
Re: Disconnection Check from server side
Hey,
Thanks Lapo for your reply it really helped me. I have one more doubt. it's regarding storing some variables on the extension like I have made my own data structure using some classes. now I want to store values in that. I have some restrictions so I am not using room or user variables. I tried storing data in static variables and it worked but I can't go with this approach also because of their static nature.
I read something about the class model which can stay inside _lib_ folder but I can't find any resource which can explain this process better. what is the model class? where to keep it in my development environment so that I don't get any compile errors and how this could help with data storing without static variables or those files can have static variables?. I have gone through http://docs2x.smartfoxserver.com/ExtensionsJava/advanced-concepts#classLoading link.
or is there any other way where I can access these variables from other classes without making them static? I want to access these variables within the same room extension.
Thanks.
Thanks Lapo for your reply it really helped me. I have one more doubt. it's regarding storing some variables on the extension like I have made my own data structure using some classes. now I want to store values in that. I have some restrictions so I am not using room or user variables. I tried storing data in static variables and it worked but I can't go with this approach also because of their static nature.
I read something about the class model which can stay inside _lib_ folder but I can't find any resource which can explain this process better. what is the model class? where to keep it in my development environment so that I don't get any compile errors and how this could help with data storing without static variables or those files can have static variables?. I have gone through http://docs2x.smartfoxserver.com/ExtensionsJava/advanced-concepts#classLoading link.
or is there any other way where I can access these variables from other classes without making them static? I want to access these variables within the same room extension.
Code: Select all
public class mainRoom extends SFSExtension {
public static PlayersData _playersData = new PlayersData(new ArrayList<UserData>(), 0); // set MMTime And maxGame time in Config
public static Timer MMtimer = new Timer();
public static Timer GameTimer = new Timer();
Thanks.
Re: Disconnection Check from server side
I got a solution for the problem. I am passing the main class (where all variable resides) in the constructor for every class that needs a reference for variables. now I can have access to all the variables with that reference.
Thanks.
Thanks.
Who is online
Users browsing this forum: No registered users and 126 guests