Example #1
0
 public static void AddServer(FightServer server)
 {
     if (!m_list.Contains(server))
     {
         m_list.Add(server);
     }
 }
Example #2
0
 public static void RemoveServer(FightServer server)
 {
     if (m_list.Contains(server))
     {
         m_list.Remove(server);
     }
 }
Example #3
0
        public static void ConnectFightServers()
        {
            string[] list = GSConfigMgr.Configuration.BattleServerList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            if (list.Length == 0 || string.IsNullOrEmpty(list[0]))
            {
                log.Error("未配置战斗服务器!");
                return;
            }

            foreach (string str in list)
            {
                string[] address = str.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

                if (address.Length < 2)
                {
                    log.Error("战斗服务器配置错误!");
                    return;
                }

                FightServer server = new FightServer("战斗服务器(" + str + ")");

                server.Connect(address[0], int.Parse(address[1]));
            }
        }
Example #4
0
        public static void ConnectFightServers()
        {
            string[] list = GSConfigMgr.Configuration.BattleServerList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            if (list.Length == 0 || string.IsNullOrEmpty(list[0]))
            {
                log.Error("未配置战斗服务器!");
                return;
            }

            foreach (string str in list)
            {
                string[] address = str.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

                if (address.Length < 2)
                {
                    log.Error("战斗服务器配置错误!");
                    return;
                }

                FightServer server = new FightServer("战斗服务器(" + str + ")");

                server.Connect(address[0], int.Parse(address[1]));
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            //Ratio a = new Ratio(-1,2);
            //Ratio b = new Ratio(-1,2);

            //Console.WriteLine(a.ToString());
            //a.Sub(b);
            //Console.WriteLine(a.ToString());
            //a.Division(b);
            //Console.WriteLine(a.ToString());
            //ProtocolBase protocol = new ByteProtocol();
            //protocol.push(1);//4
            //protocol.push("123123");//12 +2
            //protocol.push((byte)3);//1
            //protocol.push(new Ratio(9, 20));
            //protocol.push(true);//1
            //protocol.push("卧槽");//4 +2

            //protocol.InitMessage(protocol.GetByteStream());

            //Console.WriteLine(protocol.getInt32());
            //Console.WriteLine(protocol.getString());
            //Console.WriteLine(protocol.getByte());
            //Console.WriteLine(protocol.getRatio());
            //Console.WriteLine(protocol.getBoolean());
            //Console.WriteLine(protocol.getString());

            FightServer fightServer = new FightServer();
            fightServer.StartServer("127.0.0.1", 12345, 5);
            while (true)
            {
                Console.ReadLine();
            }
        }
Example #6
0
 public static void AddServer(FightServer server)
 {
     if (!m_list.Contains(server))
     {
         m_list.Add(server);
     }
 }
Example #7
0
        public static FightServer[] GetAllFightServer()
        {
            FightServer[] list = new FightServer[m_list.Count];

            m_list.CopyTo(list, 0);

            return(list);
        }
Example #8
0
        public static FightServer[] GetAllFightServer()
        {
            FightServer[] list = new FightServer[m_list.Count];

            m_list.CopyTo(list, 0);

            return list;
        }
Example #9
0
 public bool StartFight()
 {
     if (!FightStatus)
     {
         new Thread(() => { FightServer.StartServer(); }).Start();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #10
0
        public static FightServer AcquireServer()
        {
            lock (LockHelper)
            {
                if (!HasServer)
                {
                    return(null);
                }

                FightServer server = m_list[0];
                if (m_list.Count > 1)
                {
                    m_list.RemoveAt(0);
                    m_list.Add(server);
                }
                return(server);
            }
        }
Example #11
0
        /// <summary>
        /// Handles the server action
        /// </summary>
        /// <param name="parameters"></param>
        public void OnAction(Hashtable parameters)
        {
            Console.WriteLine("This server DDTankII, edit and build by Trminhpc!");
            Console.WriteLine("Starting FightingServer ... please wait a moment!");

            FightServerConfig config = new FightServerConfig();

            try
            {
                config.Load();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
                return;
            }

            FightServer.CreateInstance(config);
            FightServer.Instance.Start();

            bool run = true;

            while (run)
            {
                try
                {
                    Console.Write("> ");
                    string   line = Console.ReadLine();
                    string[] para = line.Split(' ');

                    switch (para[0].ToLower())
                    {
                    case "clear":
                        Console.Clear();
                        break;

                    case "list":
                        if (para.Length > 1)
                        {
                            switch (para[1])
                            {
                            case "-client":
                                Console.WriteLine("server client list:");
                                Console.WriteLine("--------------------");
                                ServerClient[] list = FightServer.Instance.GetAllClients();
                                foreach (ServerClient client in list)
                                {
                                    Console.WriteLine(client.ToString());
                                }
                                Console.WriteLine("-------------------");
                                break;

                            case "-room":
                                Console.WriteLine("room list:");
                                Console.WriteLine("-------------------------------");
                                ProxyRoom[] rooms = ProxyRoomMgr.GetAllRoom();
                                foreach (ProxyRoom room in rooms)
                                {
                                    Console.WriteLine(room.ToString());
                                }
                                Console.WriteLine("-------------------------------");
                                break;

                            case "-game":
                                Console.WriteLine("game list:");
                                Console.WriteLine("-------------------------------");
                                List <BaseGame> games = GameMgr.GetGames();
                                foreach (BaseGame g in games)
                                {
                                    Console.WriteLine(g.ToString());
                                }
                                Console.WriteLine("-------------------------------");
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("list [-client][-room][-game]");
                            Console.WriteLine("     -client:列出所有服务器对象");
                            Console.WriteLine("     -room:列出所有房间对象");
                            Console.WriteLine("     -game:列出所有游戏对象");
                        }

                        break;

                    case "exit":
                        run = false;
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error:" + ex.ToString());
                }
            }

            if (FightServer.Instance != null)
            {
                FightServer.Instance.Stop();
            }
        }
Example #12
0
        public void OnAction(System.Collections.Hashtable parameters)
        {
            System.Console.WriteLine("This server GunnyII, edit and build by MrPhuong!");
            System.Console.WriteLine("Starting FightingServer ... please wait a moment!");
            FightServerConfig fightServerConfig = new FightServerConfig();

            try
            {
                fightServerConfig.Load();
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Console.ReadKey();
                return;
            }
            FightServer.CreateInstance(fightServerConfig);
            FightServer.Instance.Start();
            bool flag = true;

            while (flag)
            {
                try
                {
                    System.Console.Write("> ");
                    string   text  = System.Console.ReadLine();
                    string[] array = text.Split(new char[]
                    {
                        ' '
                    });
                    string a;
                    if ((a = array[0].ToLower()) != null)
                    {
                        if (!(a == "clear"))
                        {
                            if (!(a == "list"))
                            {
                                if (a == "exit")
                                {
                                    flag = false;
                                }
                            }
                            else
                            {
                                if (array.Length > 1)
                                {
                                    string a2;
                                    if ((a2 = array[1]) != null)
                                    {
                                        if (!(a2 == "-client"))
                                        {
                                            if (!(a2 == "-room"))
                                            {
                                                if (a2 == "-game")
                                                {
                                                    System.Console.WriteLine("game list:");
                                                    System.Console.WriteLine("-------------------------------");
                                                    System.Collections.Generic.List <BaseGame> games = GameMgr.GetGames();
                                                    foreach (BaseGame current in games)
                                                    {
                                                        System.Console.WriteLine(current.ToString());
                                                    }
                                                    System.Console.WriteLine("-------------------------------");
                                                }
                                            }
                                            else
                                            {
                                                System.Console.WriteLine("room list:");
                                                System.Console.WriteLine("-------------------------------");
                                                ProxyRoom[] allRoom = ProxyRoomMgr.GetAllRoom();
                                                ProxyRoom[] array2  = allRoom;
                                                for (int i = 0; i < array2.Length; i++)
                                                {
                                                    ProxyRoom proxyRoom = array2[i];
                                                    System.Console.WriteLine(proxyRoom.ToString());
                                                }
                                                System.Console.WriteLine("-------------------------------");
                                            }
                                        }
                                        else
                                        {
                                            System.Console.WriteLine("server client list:");
                                            System.Console.WriteLine("--------------------");
                                            ServerClient[] allClients = FightServer.Instance.GetAllClients();
                                            ServerClient[] array3     = allClients;
                                            for (int j = 0; j < array3.Length; j++)
                                            {
                                                ServerClient serverClient = array3[j];
                                                System.Console.WriteLine(serverClient.ToString());
                                            }
                                            System.Console.WriteLine("-------------------");
                                        }
                                    }
                                }
                                else
                                {
                                    System.Console.WriteLine("list [-client][-room][-game]");
                                    System.Console.WriteLine("     -client:列出所有服务器对象");
                                    System.Console.WriteLine("     -room:列出所有房间对象");
                                    System.Console.WriteLine("     -game:列出所有游戏对象");
                                }
                            }
                        }
                        else
                        {
                            System.Console.Clear();
                        }
                    }
                }
                catch (System.Exception ex2)
                {
                    System.Console.WriteLine("Error:" + ex2.ToString());
                }
            }
            if (FightServer.Instance != null)
            {
                FightServer.Instance.Stop();
            }
        }
Example #13
0
 public static void RemoveServer(FightServer server)
 {
     if (m_list.Contains(server))
     {
         m_list.Remove(server);
     }
 }