Exemplo n.º 1
0
        private void findCurrentServer()
        {
            //使用Infoservice的IP和端口来
            Uri    uri  = new Uri(_clientHub.BaseAddress);
            string ip   = IpCorrector.CorrectIp(uri.Host);
            int    port = uri.Port;

            CCTVServerInfo[] sis = _clientHub.GetAllServerInfo();
            foreach (CCTVServerInfo si in sis)
            {
                if (ip.Equals(si.InfoServiceIp) && port == si.InfoServicePort)
                {
                    _currentServer = new CCTVServerInfo()
                    {
                        ServerId          = si.ServerId,
                        Name              = si.Name,
                        InfoServiceIp     = si.InfoServiceIp,
                        InfoServicePort   = si.InfoServicePort,
                        StreamServerIp    = si.StreamServerIp,
                        StreamServerPort  = si.StreamServerPort,
                        ControlServerIp   = si.ControlServerIp,
                        ControlServerPort = si.ControlServerPort
                    };
                    break;
                }
            }
            if (_currentServer == null)
            {
                _currentServer = new CCTVServerInfo()
                {
                    ServerId          = Guid.NewGuid().ToString(),
                    Name              = "独立信息服务",
                    InfoServiceIp     = ip,
                    InfoServicePort   = port,
                    StreamServerIp    = ip,
                    StreamServerPort  = 37010,
                    ControlServerIp   = ip,
                    ControlServerPort = 47010
                };
            }
        }