Hi,
Yesterday everything is ok.But Today,the server is mad and sending players message without interval.It seems that the "ScheduleCallback"
become crazy.By the way,it is still ok on the local server.
Below is the code.
private DateTime lastFrameTime;
[RoomType("PCSGame")]
public class GameCode : Game<Player>
{
.......
public int FrameDuring = 40;
private DateTime lastFrameTime;
.......
private void gameFrame()
{
Message f = Message.Create("f");//frame input
......
Broadcast(f);
DateTime currentFrameTime = DateTime.Now;
TimeSpan executionTime = currentFrameTime - lastFrameTime;
lastFrameTime = currentFrameTime;
int restTimeMS = 2*FrameDuring-(int)executionTime.TotalMilliseconds;
//Run again
int dueTime=Math.Min(restTimeMS - msgTimeMS, FrameDuring - msgTimeMS);
if (dueTime <= 25)
{
gameFrame();
}
else
{
ScheduleCallback(gameFrame, dueTime);
}
}