static void Server() { Lobby.Init(); //GSQLite.Open(sqlpath); GSrv.Init(); GSrv.SetConnectPacketHandler(ConnectHandler); GSrv.SetDisconnectPacketHandler(DisconnectHandler); GSrv.SetDebugPacketHandler(DebugHandler); GSrv.SetPacketHandler(MessageType.SendUserName, DataType.String, SendUserNameHandler); GSrv.SetPacketHandler(MessageType.RequestLobbyState, DataType.Null, RequestLobbyStateHandler); GSrv.SetPacketHandler(MessageType.EnterRoom, DataType.Int32, EnterRoomHandler); GSrv.SetPacketHandler(MessageType.LeaveRoom, DataType.Null, LeaveRoomHandler); GSrv.SetPacketHandler(MessageType.ChangeFaction, DataType.Null, ChangeFactionHandler); GSrv.SetPacketHandler(MessageType.ChangeReady, DataType.Null, ChangeReadyHandler); GSrv.SetPacketHandler(MessageType.Push, DataType.Bytes, PushHandler); GSrv.SetPacketHandler(MessageType.TouchCore, DataType.Null, TouchCoreHandler); GSrv.SetPacketHandler(MessageType.SetBlock, DataType.Bytes, SetBlockHandler); GSrv.SetPacketHandler(MessageType.SendFire, DataType.Bytes, SendFireHandler); GSrv.Listen("ILSnowballFight0.1", port); while (!exit) { DateTime startTime = DateTime.Now; GSrv.Receive(); sendCount++; if (sendCount == 3) { sendCount = 0; SendSnapshot(); } Update(frameSpan); TimeSpan span = DateTime.Now - startTime; if (span.TotalMilliseconds < frameSpan * 1000) { Thread.Sleep((int)(frameSpan * 1000) - (int)span.TotalMilliseconds); } } GSrv.Shutdown(); /*Players.SaveAllPlayer(); * GSQLite.Close();*/ }
static void Server() { //GSQLite.Open(sqlpath); GSrv.Init(); GSrv.SetConnectPacketHandler(ConnectHandler); GSrv.SetDisconnectPacketHandler(DisconnectHandler); GSrv.SetDebugPacketHandler(DebugHandler); GSrv.SetPacketHandler(MessageType.Push, DataType.Bytes, PushHandler); GSrv.SetPacketHandler(MessageType.Draw, DataType.Bytes, DrawHandler); GSrv.Listen("TwoDimBlocks0.1", port); while (!exit) { DateTime startTime = DateTime.Now; GSrv.Receive(); sendCount++; if (sendCount == 3) { sendCount = 0; SendSnapshot(); } Update(frameSpan); TimeSpan span = DateTime.Now - startTime; if (span.TotalMilliseconds < frameSpan * 1000) { Thread.Sleep((int)(frameSpan * 1000) - (int)span.TotalMilliseconds); } } GSrv.Shutdown(); /*Players.SaveAllPlayer(); * GSQLite.Close();*/ }