Пример #1
0
        private void RegisterRoomServer()
        {
            RequestParam param = new RequestParam();

            param.Add("Port", ConfigUtils.GetSetting("Game.Port"));
            param.Add("Host", ConfigUtils.GetSetting("Game.Host"));
            LobbyServerSender.Send("RLRegisterRoomServerHandler", param, callback =>
            {
                TraceLog.ReleaseWrite("RegisterRoomServer OK.");
            });
        }
Пример #2
0
        private void UpdateServerState(object state)
        {
            RequestParam param = new RequestParam();

            param.Add("RoomCount", CacheSet.RoomCache.Count);
            param.Add("CpuLoad", 20 * 1000);
            param.Add("MemoryLoad", 20 * 1000);
            LobbyServerSender.Send("RLUpdateServerStateHandler", param, callback =>
            {
                TraceLog.ReleaseWrite("UpdateServerState OK.");
            });
        }
Пример #3
0
        private static Dictionary <string, string> GetAllConfigs()
        {
            Dictionary <string, string> ret = new Dictionary <string, string>();
            RequestParam param = new RequestParam();

            LobbyServerSender.Send("RLGetGameConfigsHandler", param, callback => {
                var res = RemoteCommunication.ParseRemotePackage <LRGetGameConfigs>(callback.Message as byte[]);
                for (int i = 0; i < res.Keys.Count; i++)
                {
                    ret.Add(res.Keys[i], res.Values[i]);
                }
            });
            return(ret);
        }
Пример #4
0
        public void UpdateFinish()
        {
            if (DateTime.UtcNow.Ticks - m_Room.StartTime > Constants.RoomExpireTime * TimeSpan.TicksPerSecond)
            {
                RWPvpResult result = new RWPvpResult();
                foreach (var player in m_Room.Players)
                {
                    result.PlayerIds.Add(player.Value.PlayerId);
                    result.ServerId.Add(player.Value.ServerId);
                    result.Result.Add((int)player.Value.State);
                    var session = GameSession.Get(player.Key);
                    if (session != null)
                    {
                        session.Close();
                    }
                }
                if (result.PlayerIds.Count > 0)
                {
                    LobbyServerSender.Send("RWPvpResultHandler", result, callback => { });
                }
                RoomManager.GetInstance(m_Room.Id).CloseRoom();
                return;
            }
            RWPvpResult resultPacket = new RWPvpResult();

            foreach (var player in m_Room.Players)
            {
                if (player.Value.State == RoomPlayerState.Winned || player.Value.State == RoomPlayerState.Failed || player.Value.State == RoomPlayerState.Draw)
                {
                    resultPacket.PlayerIds.Add(player.Value.PlayerId);
                    resultPacket.ServerId.Add(player.Value.ServerId);
                    resultPacket.Result.Add((int)player.Value.State);
                    var session = GameSession.Get(player.Value.PlayerId);
                    if (session != null)
                    {
                        RCPushBattleResult packet = new RCPushBattleResult()
                        {
                            Result = (int)player.Value.State,
                            Reason = (int)m_Room.EndReason,
                        };
                        byte[] buffer = CustomActionDispatcher.GeneratePackageStream((int)ActionType.RCPushBattleResult, ProtoBufUtils.Serialize(packet));
                        session.SendAsync(buffer, 0, buffer.Length);
                    }
                    player.Value.State = RoomPlayerState.Exited;
                }
                else
                {
                    continue;
                }
            }
            if (resultPacket.PlayerIds.Count > 1)
            {
                TraceLog.WriteInfo("Player1:{0},win=>{1}\nPlayer2:{2},win=>{3}", resultPacket.PlayerIds[0], resultPacket.Result[0], resultPacket.PlayerIds[1], resultPacket.Result[1]);
                LobbyServerSender.Send("RWPvpResultHandler", resultPacket, callback => { });
            }

            bool allExited = true;

            foreach (var player in m_Room.Players)
            {
                if (player.Value.State != RoomPlayerState.Exited)
                {
                    allExited = false;
                }
            }
            if (allExited)
            {
                RoomManager.GetInstance(m_Room.Id).CloseRoom();
                return;
            }
        }