Exemple #1
0
        //public event LoginEvent LoginResult_Event;
        public HSCmdCenter()
        {
            HsNetWork hsNetwork = null;

            string            strNetworkFileName = "wwwroot/conf/NetWork.json";
            string            jsonString         = File.ReadAllText(strNetworkFileName);
            List <ISGNetwork> listNetworks       = new List <ISGNetwork>();

            using (JsonDocument document = JsonDocument.Parse(jsonString))
            {
                JsonElement root           = document.RootElement;
                JsonElement NetWorkElement = root.GetProperty("NETWORKS");
                //JsonElement Element;
                foreach (JsonElement netElement in NetWorkElement.EnumerateArray())
                {
                    SGNetwork sgNet          = new SGNetwork();
                    string    strJsonElement = netElement.ToString();
                    var       options        = new JsonSerializerOptions
                    {
                        ReadCommentHandling         = JsonCommentHandling.Skip,
                        AllowTrailingCommas         = true,
                        PropertyNameCaseInsensitive = true,
                    };
                    sgNet = JsonSerializer.Deserialize <SGNetwork>(strJsonElement, options);
                    listNetworks.Add(sgNet);
                }
            }

            int count = listNetworks.Count;

            for (int i = 0; i < count; i++)
            {
                string strIP   = listNetworks[i].IPAddress;
                int    port    = listNetworks[i].Port;
                int    groupID = listNetworks[i].GroupID;
                hsNetwork = new HsNetWork();
                hsNetwork.Init(strIP, port, 0, SslProtocols.Tls12, "");    // basedir 정해진 후 설정 필요
                hsNetwork.SGData_EventReg(SGDataRecv);
                hsNetwork.SetGroupID(groupID);
                m_DicNetWork[groupID] = hsNetwork;
            }
        }