コード例 #1
0
ファイル: Program.cs プロジェクト: ypdevman/Zero
        static void Main(string[] args)
        {
            UInt16 portnum = CasualCommonSvr.Room.portnum;

            // 로드벨런싱을 위한 여러개의 서버를 실행하기 위해 이 서버의 Listen Port번호를 파라미터로 입력가능
            if (args.Length == 1)
            {
                portnum = UInt16.Parse(args[0]);
            }

            RoomServer Svr = new RoomServer();

            ZNet.StartOption param = new ZNet.StartOption();
            param.m_IpAddressListen     = CasualCommonSvr.Room.ipaddr;
            param.m_PortListen          = portnum;
            param.m_MaxConnectionCount  = 50000;
            param.m_RefreshServerTickMs = 10000;
            param.m_ProtocolVersion     = CasualCommon.Join.protocol_ver;

            Svr.m_Core.SetKeepAliveOption(30);

            ZNet.ResultInfo outResult = new ZNet.ResultInfo();
            if (Svr.m_Core.Start(param, outResult))
            {
                Console.WriteLine("RoomServer Start ok.\n");
                DisplayCommand();
            }
            else
            {
                Console.WriteLine("Start error : {0} \n", outResult.msg);
            }

            Svr.m_Core.MasterConnect(
                CasualCommonSvr.MasterServerConnect.master_ipaddr,
                CasualCommonSvr.MasterServerConnect.master_portnum,
                "RoomServer",
                (int)CasualCommon.Server.Room
                );

            var ret = CasualCommon.Common.ReadLineAsync();

            while (Svr.run_program)
            {
                if (ret.IsCompleted)
                {
                    switch (ret.Result)
                    {
                    case "/h":
                        DisplayCommand();
                        break;

                    case "/stat":
                        CasualCommonSvr.Common.DisplayStatus(Svr.m_Core);
                        break;

                    case "/room":
                        if (Svr.RemoteRooms.Count > 0)
                        {
                            foreach (var obj in Svr.RemoteRooms)
                            {
                                Console.WriteLine("room {0}/{1}", obj.Value.users.Count, obj.Value.max_users);
                            }
                        }
                        else
                        {
                            Console.WriteLine("room empty");
                        }
                        break;

                    case "/q":
                        Console.WriteLine("quit Server...");
                        Svr.run_program = false;
                        break;
                    }

                    if (Svr.run_program)
                    {
                        ret = CasualCommon.Common.ReadLineAsync();
                    }
                }

                System.Threading.Thread.Sleep(10);
            }

            Console.WriteLine("Start Closing...  ");
            Svr.m_Core.Dispose();
            Console.WriteLine("Close complete.");

            System.Threading.Thread.Sleep(1000 * 2);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: hothoty/Zero
        static void Main(string[] args)
        {
            UInt16 portnum = CasualCommonSvr.Room.portnum;

            // 로드벨런싱을 위한 여러개의 서버를 실행하기 위해 이 서버의 Listen Port번호를 파라미터로 입력가능
            if (args.Length == 1)
            {
                portnum = UInt16.Parse(args[0]);
            }

            RoomServer Svr = new RoomServer();

            ZNet.StartOption param = new ZNet.StartOption();
            param.m_IpAddressListen = CasualCommonSvr.Room.ipaddr;
            param.m_PortListen = portnum;
            param.m_MaxConnectionCount = 50000;
            param.m_RefreshServerTickMs = 10000;
            param.m_ProtocolVersion = CasualCommon.Join.protocol_ver;

            Svr.m_Core.SetKeepAliveOption(30);

            ZNet.ResultInfo outResult = new ZNet.ResultInfo();
            if (Svr.m_Core.Start(param, outResult))
            {
                Console.WriteLine("RoomServer Start ok.\n");
                DisplayCommand();
            }
            else
            {
                Console.WriteLine("Start error : {0} \n", outResult.msg);
            }

            Svr.m_Core.MasterConnect(
                CasualCommonSvr.MasterServerConnect.master_ipaddr,
                CasualCommonSvr.MasterServerConnect.master_portnum,
                "RoomServer",
                (int)CasualCommon.Server.Room
                );

            var ret = CasualCommon.Common.ReadLineAsync();
            while (Svr.run_program)
            {
                if (ret.IsCompleted)
                {
                    switch (ret.Result)
                    {
                        case "/h":
                            DisplayCommand();
                            break;

                        case "/stat":
                            CasualCommonSvr.Common.DisplayStatus(Svr.m_Core);
                            break;

                        case "/room":
                            if (Svr.RemoteRooms.Count > 0)
                            {
                                foreach (var obj in Svr.RemoteRooms)
                                {
                                    Console.WriteLine("room {0}/{1}", obj.Value.users.Count, obj.Value.max_users);
                                }
                            }
                            else
                            {
                                Console.WriteLine("room empty");
                            }
                            break;

                        case "/q":
                            Console.WriteLine("quit Server...");
                            Svr.run_program = false;
                            break;
                    }

                    if (Svr.run_program)
                        ret = CasualCommon.Common.ReadLineAsync();
                }

                System.Threading.Thread.Sleep(10);
            }

            Console.WriteLine("Start Closing...  ");
            Svr.m_Core.Dispose();
            Console.WriteLine("Close complete.");

            System.Threading.Thread.Sleep(1000 * 2);
        }