Пример #1
0
        /// <summary>
        /// 平台方式初始化插件
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public void InitPlayerP(int videotype, string ip, int port, string username, string password)
        {
            //if (isPlatLogin && loginType == videotype)
            //{
            //    return;
            //}

            Reset();

            PluginType = PluginType.PlatForm_Connection_Plugin;

            switch (videotype)
            {
            //英飞拓平台
            case 101:
                PlatformSDK = new P_INFSDK();
                break;

            //海康平台
            case 102:
                PlatformSDK = new P_HIKSDK();
                break;

            default:
                ShowError("尚未支持的平台类型!");
                break;
            }
            try
            {
                LoginInfo linfo = new LoginInfo()
                {
                    Ip       = ip,
                    Port     = port,
                    UserName = username,
                    Password = password
                };


                Player1.VideoInfo.LoginInfo = linfo;
                Player2.VideoInfo.LoginInfo = linfo;
                Player3.VideoInfo.LoginInfo = linfo;
                Player4.VideoInfo.LoginInfo = linfo;

                PlatformSDK.VideoInfo = Player1.VideoInfo;

                PlatformSDK.Init();
                PlatformSDK.Login(linfo);
                Player1.SDK = PlatformSDK;
                Player2.SDK = PlatformSDK;
                Player3.SDK = PlatformSDK;
                Player4.SDK = PlatformSDK;

                isPlatLogin = true;
                loginType   = videotype;
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Пример #2
0
        void Reset()
        {
            int id = ActivePlayer.Index;

            Player1.ReInit();
            Player2.ReInit();
            Player3.ReInit();
            Player4.ReInit();
            SetPlayerActive(id);

            switch (PluginType)
            {
            case PluginType.Direct_Connection_Plugin:
                break;

            case PluginType.PlatForm_Connection_Plugin:
                try
                {
                    PlatformSDK.LogOut();
                }catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                PlatformSDK = null;
                break;

            default:
                break;
            }
            isPlatLogin = false;
            loginType   = -1;
        }
Пример #3
0
 /// <summary>
 /// 注册SDK平台
 /// </summary>
 /// <param name="key"></param>
 /// <param name="iSdk"></param>
 /// <returns></returns>
 static bool RegisteSDK(Type key, ISDK iSdk)
 {
     if (!allSDKDic.ContainsKey(key))
     {
         allSDKDic.Add(key, iSdk);
         SDKDebug(allSDKDic[key].Name + "注册成功");
         return(true);
     }
     return(false);
 }
Пример #4
0
        public void Release()
        {
            try
            {
                Player1.Release();
                Player2.Release();
                Player3.Release();
                Player4.Release();

                Player1 = new SinglePlayer();
                Player2 = new SinglePlayer();
                Player3 = new SinglePlayer();
                Player4 = new SinglePlayer();

                PlatformSDK = new P_HIKSDK();
            }
            catch
            {
            }
        }
Пример #5
0
 //-------------------------
 private LynSdkManager()
 {
     Isdk = ConcreateSdk();
 }
Пример #6
0
        private void ConfigureSDK()
        {
            string brandID = Helpers.Resource.Get <string>("BRAND_NAME", "WLSDK");

            brandID = brandID.Replace(" ", string.Empty);

            string logFilesPath = Path.Combine(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.LocalApplicationData,
                    Environment.SpecialFolderOption.Create),
                brandID,
                "Logs",
                "SDK.log");

            if (string.IsNullOrEmpty(Helpers.Resource.Get <string>("API_KEY")) ||
                string.IsNullOrEmpty(Helpers.Resource.Get <string>("AUTHORIZATION_TOKEN")))
            {
                throw new VpnSDKInvalidConfigurationException("API key or Authorization token was not set.");
            }

            /*
             * The values for the API_KEY and AUTHORIZATION_TOKEN for this example app are stored in Resources\Branding\apiaccess.xaml.
             * You must replace those placeholder values with a real key and authorization token
             * To obtain these values you need to be a registered WLVPN reseller.
             * If you have not done so already, please visit https://wlvpn.com/#contact to get started.
             */
            _manager = new SDKBuilder()
                       .SetApiKey(Helpers.Resource.Get <string>("API_KEY"))
                       .SetApplicationName(Helpers.Resource.Get <string>("BRAND_NAME"))
                       .SetAuthenticationToken(Helpers.Resource.Get <string>("AUTHORIZATION_TOKEN"))
                       .SetLogFilesPath(logFilesPath)
                       .SetServerListCache(TimeSpan.FromDays(1))
                       .SetOpenVpnConfiguration(new OpenVpnConfiguration
            {
                OpenVpnCertificateFileName = "ca.crt",
                OpenVpnDirectory           = "OpenVPN",
                OpenVpnExecutableFileName  = "openvpn.exe",
                OpenVpnConfigDirectory     = "OpenVPN",
                OpenVpnConfigFileName      = "config.ovpn",
                OpenVpnLogFileName         = "openvpn.log",
                TapDeviceDescription       = "TAP-Windows Adapter V9",
                TapDeviceName = "tap0901"
            })
                       .SetRasConfiguration(new RasConfiguration
            {
                RasDeviceDescription = Resource.Get <string>("BRAND_NAME")
            })
                       .Create();

            var filter = this.WhenValueChanged(t => t.Search)
                         .Throttle(TimeSpan.FromMilliseconds(250))
                         .Select(RegionFilter);

            _serverListLoader = _manager.RegionsList.Connect()
                                .Filter(x => x is IRegion || x is IBestAvailable)
                                .Filter(filter)
                                .ObserveOnDispatcher()
                                .Bind(Locations)
                                .Subscribe();

            _manager.WhenUserLocationChanged.Subscribe(info =>
            {
                switch (info.Status)
                {
                case PositionInfoStatus.Updating:
                    CurrentLocationName = "Retrieving...";
                    ExternalIPAddress   = "Retrieving...";
                    break;

                case PositionInfoStatus.Updated:
                    RunOnDisplayThread(() =>
                    {
                        CurrentLocationName = $"{info.City}, {info.Country}";
                        ExternalIPAddress   = info.IPAddress.ToString();
                        if (IsConnected)
                        {
                            _eventAggregator.Publish <ShowNotificationEvent>(new ShowNotificationEvent
                            {
                                Title = Resources.Strings.CONNECTED_VISIBLE_LOCATION_HEADER_CHANGED,
                                Text  = string.Format(Resources.Strings.CURRENT_VISIBLE_LOCATION, CurrentLocationName, string.Empty),
                            });
                        }
                    });

                    break;
                }
            });
        }
Пример #7
0
 private static void Light(ISDK busylight, int red, int blue, int green)
 {
     busylight.Light(red, blue, green);
 }
Пример #8
0
 private static void LightBG(ISDK busylight, int c1, int c2)
 {
     busylight.Light(0, c1, c2);
 }
Пример #9
0
 private static void LightRG(ISDK busylight, int c1, int c2)
 {
     busylight.Light(c1, 0, c2);
 }
Пример #10
0
 private static void LightRB(ISDK busylight, int c1, int c2)
 {
     busylight.Light(c1, c2, 0);
 }