I need to show a clock to the users while getting the time from the server.
So that the users from different part of the world can have a common clock depending on which they can meet at some locations.
The clock needs to be running all the time and whenever the client-user logs in, the time should be displayed on clock icon.
How to get time from server?
Need server timer
Re: Need server timer
In the server login response you could send the server time, and then create a timer on the client which updates it each second.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: Need server timer
Thanx for reply Bax,
Please elaborate, How exactly do I get server time? (only server uptime is there)!!!
Please elaborate, How exactly do I get server time? (only server uptime is there)!!!
Re: Need server timer
Server time is not much related to the SmartFoxServer API.
It's just a matter of getting the time using the Java standard library (aka JDK)
Take a look here for example:
http://www.tutorialspoint.com/java/java_date_time.htm
It's just a matter of getting the time using the Java standard library (aka JDK)
Take a look here for example:
http://www.tutorialspoint.com/java/java_date_time.htm
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
Re: Need server timer
In the old SFS1X extensions it was very easy to get the server time.
I think the SFS2X method is something like this:
I think the SFS2X method is something like this:
Code: Select all
package com.xxx.myProject.requestHandlers;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import java.util.Date;
public class JoinBotRoomRequestHandler extends BaseClientRequestHandler
{
@Override
public void handleClientRequest(User user, ISFSObject params) {
Date date = new Date();
trace(date.toString());
}
}
Re: Need server timer
Java has several ways to deal with date/time.
See here:
http://www.mkyong.com/java/java-how-to- ... -calender/
and here too:
http://stackoverflow.com/questions/5175 ... me-in-java
The "Joda" library referenced in the articles is also provided with SFS2X, so you can use that as well, especially if you need to execute time-based calculations.
Cheers
See here:
http://www.mkyong.com/java/java-how-to- ... -calender/
and here too:
http://stackoverflow.com/questions/5175 ... me-in-java
The "Joda" library referenced in the articles is also provided with SFS2X, so you can use that as well, especially if you need to execute time-based calculations.
Cheers
Return to “SFS2X ActionScript 3 API”
Who is online
Users browsing this forum: No registered users and 40 guests