Exemplo n.º 1
0
 private void GalaxyClient_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_Net != null)
     {
         _Net.Dispose();
         _Net = null;
     }
 }
Exemplo n.º 2
0
        public GameClientTest()
        {
            InitializeComponent();

            try
            {
                var SetupJson = (JsonDataObject)JsonParser.Parse(File.ReadAllText("Option.ini"));

                _Auto    = SetupJson["Auto"].GetBool();
                ServerNo = SetupJson["ServerNo"].GetInt32();
                var ServerInfo = ((JsonDataObject)(((JsonDataArray)SetupJson["Servers"])[ServerNo]));

                StartNum  = ServerInfo["StartNum"].GetUInt32();
                ClientCnt = ServerInfo["ClientCnt"].GetInt32();
                if (ClientCnt <= 0)
                {
                    throw new Exception("Invalid ClientCnt");
                }

                DataPath = ServerInfo["DataPath"].GetString();
                IP       = ServerInfo["IP"].GetString();
                Port     = ServerInfo["Port"].GetUInt16();

                ID = ServerInfo["ID"].GetString();
                PW = ServerInfo["PW"].GetString();

                TimerNet.Enabled = true;

                if (_Auto)
                {
                    btnLoginUID.Enabled = false;
                }

                btnDisconnect.Enabled = false;

                _Net = new rso.game.CClient(
                    Link, LinkFail, UnLink, Recv, LinkSoft, UnLinkSoft,
                    Check, CheckFail,
                    new SVersion(0, 0));
                if (_Net == null)
                {
                    return;
                }

                _Binder = new CClientBinder(_Net);

                _Clients = new SClient[ClientCnt];

                for (TPeerCnt i = 0; i < ClientCnt; ++i)
                {
                    _Clients[i] = new SClient(i);
                    _Clients[i].Initialize();
                }

                _Binder.AddSendProto <SGameProtoNetCs>((Int32)EProtoNetCs.GameProto);

                _Binder.AddRecvProto((Int32)EProtoNetSc.GameProto, GameProtoNetSc);

                TimerNet.Enabled = true;
                _Graphics        = this.CreateGraphics();
            }
            catch (Exception Exception_)
            {
                _Log(Exception_.ToString());
                return;
            }
        }