private void BriaPhoneRemoteControl_Load(object sender, EventArgs e)
        {
            // Use delegates to handle events to ensure GUI updates happen on the Main Thread
            onConnectedDelegate    = new OnConnectedDelegate(MainThread_OnConnected);
            onErrorDelegate        = new OnErrorDelegate(MainThread_OnError);
            onDisconnectedDelegate = new OnDisconnectedDelegate(MainThread_OnDisconnected);

            onPhoneStatusDelegate           = new OnPhoneStatusDelegate(MainThread_OnPhoneStatus);
            onCallStatusDelegate            = new OnCallStatusDelegate(MainThread_OnCallStatus);
            onCallOptionsStatusDelegate     = new OnCallOptionsStatusDelegate(MainThread_OnCallOptionsStatus);
            onAudioPropertiesStatusDelegate = new OnAudioPropertiesStatusDelegate(MainThread_OnAudioPropertiesStatus);
            onMissedCallsStatusDelegate     = new OnMissedCallsStatusDelegate(MainThread_OnMissedCallsStatus);
            onVoiceMailStatusDelegate       = new OnVoiceMailStatusDelegate(MainThread_OnVoiceMailStatus);
            onCallHistoryStatusDelegate     = new OnCallHistoryStatusDelegate(MainThread_OnCallHistoryStatus);
            onSystemSettingsStatusDelegate  = new OnSystemSettingsStatusDelegate(MainThread_OnSystemSettingsStatus);
            onErrorReceivedDelegate         = new OnErrorReceivedDelegate(MainThread_OnErrorReceived);

            briaAPI.OnStatusChanged += new EventHandler <BriaAPI.StatusChangedEventArgs>(OnStatusChanged);

            briaAPI.OnPhoneStatus           += new EventHandler <BriaAPI.PhoneStatusEventArgs>(OnPhoneStatus);
            briaAPI.OnCallStatus            += new EventHandler <BriaAPI.CallStatusEventArgs>(OnCallStatus);
            briaAPI.OnCallOptionsStatus     += new EventHandler <BriaAPI.CallOptionsStatusEventArgs>(OnCallOptionsStatus);
            briaAPI.OnAudioPropertiesStatus += new EventHandler <BriaAPI.AudioPropertiesStatusEventArgs>(OnAudioPropertiesStatus);
            briaAPI.OnMissedCallsStatus     += new EventHandler <BriaAPI.MissedCallsStatusEventArgs>(OnMissedCallsStatus);
            briaAPI.OnVoiceMailStatus       += new EventHandler <BriaAPI.VoiceMailStatusEventArgs>(OnVoiceMailStatus);
            briaAPI.OnCallHistoryStatus     += new EventHandler <BriaAPI.CallHistoryStatusEventArgs>(OnCallHistoryStatus);
            briaAPI.OnSystemSettingsStatus  += new EventHandler <BriaAPI.SystemSettingsStatusEventArgs>(OnSystemSettingsStatus);
            briaAPI.OnErrorReceived         += new EventHandler <BriaAPI.ErrorReceivedEventArgs>(OnErrorReceived);

            briaAPI.OnError        += new EventHandler(OnError);
            briaAPI.OnDisconnected += new EventHandler(OnDisconnected);
            briaAPI.OnConnected    += new EventHandler(OnConnected);

            ConnectToBria();
        }
Ejemplo n.º 2
0
        public static void LoadAudioClip(string _package, string _file, int _track
                                         , OnLoadReadyDelegate _onReady
                                         , OnLoadObjectSuccessDelegate _onSuccess
                                         , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }
            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            _onReady();

            CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) =>
            {
                Log.Debug("ResourceMgr", "load audioclip [{0}] finish...", _file);
                _onSuccess(_res);
            },
                                               _onError));
        }
Ejemplo n.º 3
0
        public static void LoadScene(string _package, string _file
                                     , OnLoadReadyDelegate _onReady
                                     , OnLoadSceneSuccessDelegate _onSuccess
                                     , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }

            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            if (SceneManager.GetActiveScene().name.Equals(_file))
            {
                return;
            }

            _onReady();
            resLoader.AppendExternalBundle(_package);
            ResBundle.AsyncLoadBundle(_package, (_bundle) =>
            {
                _onSuccess(_file);
            });
        }
Ejemplo n.º 4
0
        public static void LoadSkybox(string _package, string _file
                                      , OnLoadReadyDelegate _onReady
                                      , OnLoadObjectSuccessDelegate _onSuccess
                                      , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }

            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            _onReady();

            CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) =>
            {
                Log.Debug("ResourceMgr", "load skybox [{0}] finish...", _file);
                CameraMgr.ApplySkybox(_res as Material);
                _onSuccess(_res);
            },
                                               _onError));
        }
Ejemplo n.º 5
0
        private static string ReadFile(string fileUrl, OnErrorDelegate onError)
        {
            StreamReader sr     = new StreamReader(fileUrl, Encoding.UTF8);
            string       result = sr.ReadToEnd();

            sr.Close();
            return(result);
        }
Ejemplo n.º 6
0
        protected virtual void OnOnError(string message)
        {
            OnErrorDelegate handler = OnError;

            if (handler != null)
            {
                handler(parent, message);
            }
        }
 public IDisposable Subscribe(IObserver <T> observer)
 {
     lock (syncObject)
     {
         onNext      += observer.OnNext;
         onError     += observer.OnError;
         onCompleted += observer.OnCompleted;
     }
     return(new EventObserverCollectionHandle(this, observer));
 }
 private void Unsubscribe(IObserver <T> observer)
 {
     lock (syncObject)
     {
         // ReSharper disable DelegateSubtraction
         onNext      -= observer.OnNext;
         onError     -= observer.OnError;
         onCompleted -= observer.OnCompleted;
         // ReSharper restore DelegateSubtraction
     }
 }
Ejemplo n.º 9
0
 private void DoNotifyError(OnErrorDelegate onErrorDelegate, string errorText, string errorDescription = "")
 {
     if (onErrorDelegate != null)
     {
         onErrorDelegate(errorText, errorDescription);
     }
     else
     {
         NotifyError(errorText, errorDescription);
     }
 }
Ejemplo n.º 10
0
 public static void ReadStreamText(string _file
                                   , OnReadTextSuccessDelegate _onSuccess
                                   , OnErrorDelegate _onError)
 {
     if (string.IsNullOrEmpty(_file))
     {
         _onError("file is null");
         return;
     }
     CoroutineMgr.Start(readStreamText(_file, _onSuccess, _onError));
 }
Ejemplo n.º 11
0
 public static void ReadPersistentImage(string _uuid
                                        , OnLoadImageSuccessDelegate _onSuccess
                                        , OnErrorDelegate _onError)
 {
     if (string.IsNullOrEmpty(_uuid))
     {
         _onError("file is null");
         return;
     }
     CoroutineMgr.Start(readPersistentImage(_uuid, _onSuccess, _onError));
 }
Ejemplo n.º 12
0
        public static void Scale(string _uuid, float _x, float _y, float _z, OnErrorDelegate _onError)
        {
            GameObject go = ResourceMgr.FindGameObject(_uuid);

            if (null == go)
            {
                _onError(string.Format("{0} is not exists !!!", _uuid));
                return;
            }
            go.transform.localScale = new Vector3(_x, _y, _z);
        }
Ejemplo n.º 13
0
 public static void ReadPersistentData(string _file
                                       , OnReadDataSuccessDelegate _onSuccess
                                       , OnErrorDelegate _onError)
 {
     if (string.IsNullOrEmpty(_file))
     {
         _onError("file is null");
         return;
     }
     CoroutineMgr.Start(readPersistentData(_file, _onSuccess, _onError));
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            OnSuccessDelegate <Artigo> onSucccessHandler = OnSuccess;
            OnSuccessDelegate <LinguagemProgramacao> onSuccessLHandler = OnSuccess;

            OnErrorDelegate onErrorHandler = OnError;

            Obter(onSucccessHandler, onErrorHandler);
            Obter(onSuccessLHandler, onErrorHandler);

            Console.ReadKey();
        }
Ejemplo n.º 15
0
        public async Task <PrivateEmailInfo> GenerateNewEmail(OnErrorDelegate onErrorDelegate = null)
        {
            OnWillExecute(this);

            try
            {
                return(await GenerateNewEmailRequest(onErrorDelegate));
            }
            finally
            {
                OnDidExecute(this);
            }
        }
Ejemplo n.º 16
0
        public static void DownloadManifest(OnSuccessFinishDelegate _onFinish, OnErrorDelegate _onError)
        {
            string uri = Settings.fangs_domain + "/storage/list";

            Log.Debug("HttpMgr", "DownloadMinifest: {0}", uri);
            Dictionary <string, object> paramAry = new Dictionary <string, object>(0);

            paramAry.Add("bucket", HttpMgr.Base64Encode(Settings.beans_bucket));
            paramAry.Add("sort", HttpMgr.Base64Encode("time"));
            paramAry.Add("from", 0);
            paramAry.Add("to", 32);
            Http.Operation operation = http.AsyncPOST(uri, paramAry, (_data) =>
            {
                Log.Debug("HttpMgr", "DownloadMinifest Finish: {0}", uri);
                // parse the response
                JSONNode json = JSON.Parse(System.Text.Encoding.UTF8.GetString(_data));
                int errcode   = json["errcode"].AsInt;
                // 0 is OK
                if (0 != errcode)
                {
                    _onError(string.Format("Download manifest has error, the errorcode is {0}", errcode));
                    return;
                }

                // take all the guid of bean and put them to a array.
                int count      = json["data"]["keys:length"].AsInt;
                string[] beans = new string[count];
                for (int i = 0; i < count; ++i)
                {
                    string field = string.Format("keys:{0}", i);
                    string value = json["data"][field].Value;
                    beans[i]     = Base64Decode(value);
                }
                // save the minifest file with beans
                JSONArray beanAry = new JSONArray();
                foreach (string bean in beans)
                {
                    beanAry.Add(bean);
                }
                JSONClass root = new JSONClass();
                root.Add("beans", beanAry);
                string manifestJson = root.ToJSON(0);

                File.WriteAllText(Path.Combine(beansPath, "manifest.txt"), manifestJson);
                _onFinish();
            }, (_err) =>
            {
                Log.Error("HttpMgr", _err);
                _onError(_err.errmessage);
            });
        }
        public void UnsubscribeAll(bool sendOnCompleted)
        {
            var curCompleted = onCompleted;

            lock (syncObject)
            {
                onNext      = null;
                onError     = null;
                onCompleted = null;
            }

            if (sendOnCompleted)
            {
                curCompleted?.Invoke();
            }
        }
Ejemplo n.º 18
0
        public async Task DeleteEmail(PrivateEmailInfo emailInfo, OnErrorDelegate onErrorDelegate = null)
        {
            if (emailInfo == null)
            {
                return;
            }

            OnWillExecute(this);

            try
            {
                await DeleteEmailRequest(emailInfo, onErrorDelegate);
            }
            finally
            {
                OnDidExecute(this);
            }
        }
Ejemplo n.º 19
0
        public async Task <bool> DeleteEmailRequest(PrivateEmailInfo emailInfo, OnErrorDelegate onErrorDelegate = null)
        {
            try
            {
                CancellationTokenSource src = new CancellationTokenSource();
                await ApiServices.Instance.PrivateEmailDeleteAsync(emailInfo.Email, src.Token);

                int idx = GetEmailIndex(emailInfo);
                if (idx >= 0)
                {
                    PrivateEmails.RemoveAt(idx);
                }
                // force property updated event
                PrivateEmails = PrivateEmails;
            }
            catch (OperationCanceledException)
            {
                return(false);
            }
            catch (TimeoutException)
            {
                DoNotifyError(onErrorDelegate, __AppServices.LocalizedString("Error_ApiRequestTimeout"));
                return(false);
            }
            catch (WebException ex)
            {
                Logging.Info($"REST request exception : {ex}");
                DoNotifyError(onErrorDelegate,
                              __AppServices.LocalizedString("Error_RestServer_ConnectionError_Title"),
                              __AppServices.LocalizedString("Error_RestServer_ConnectionError"));
                return(false);
            }
            catch (Exception ex)
            {
                Logging.Info($"REST request exception : {ex}");
                DoNotifyError(onErrorDelegate, __AppServices.LocalizedString("Error_RestServer_Communication")
                              + Environment.NewLine
                              + Environment.NewLine
                              + $"{ex}");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 20
0
        public static void PreloadAnyRes(string _package, string _file
                                         , OnLoadReadyDelegate _onReady
                                         , OnLoadObjectSuccessDelegate _onSuccess
                                         , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }

            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            _onReady();
        }
Ejemplo n.º 21
0
        public void ExecuteSearch(SearchExecutor searchFunc, OnErrorDelegate onErrorFunc = null)
        {
            var s = Acquire();

            try
            {
                searchFunc(s);
            }
            catch (Exception e)
            {
                if (onErrorFunc != null)
                {
                    onErrorFunc(e);
                }
            }
            finally
            {
                Release(s);
            }
        }
Ejemplo n.º 22
0
        private async Task <PrivateEmailInfo> GenerateNewEmailRequest(OnErrorDelegate onErrorDelegate = null)
        {
            try
            {
                CancellationTokenSource src = new CancellationTokenSource();
                var response = await ApiServices.Instance.PrivateEmailGenerateAsync(src.Token);


                PrivateEmailInfo email = new PrivateEmailInfo(response.Email, response.ForwardToEmail, response.Notes);
                ObservableCollection <PrivateEmailInfo> emails = PrivateEmails;
                emails.Add(email);
                PrivateEmails = emails;

                OnNewEmailGenerated(email);
                return(email);
            } catch (OperationCanceledException) {
                return(null);
            }
            catch (TimeoutException) {
                DoNotifyError(onErrorDelegate, __AppServices.LocalizedString("Error_ApiRequestTimeout"));
                return(null);
            }
            catch (WebException ex)
            {
                Logging.Info($"REST request exception : {ex}");
                DoNotifyError(onErrorDelegate,
                              __AppServices.LocalizedString("Error_RestServer_ConnectionError_Title"),
                              __AppServices.LocalizedString("Error_RestServer_ConnectionError"));
                return(null);
            }
            catch (Exception ex)
            {
                Logging.Info($"REST request exception : {ex}");
                DoNotifyError(onErrorDelegate, __AppServices.LocalizedString("Error_RestServer_Communication")
                              + Environment.NewLine
                              + Environment.NewLine
                              + $"{IVPNException.GetDetailedMessage(ex)}");
                return(null);
            }
        }
Ejemplo n.º 23
0
        private static void Obter <T>(OnSuccessDelegate <T> onSuccess, OnErrorDelegate onError) where T : class
        {
            try
            {
                var artigos = new List <Artigo>();
                artigos.Add(new Artigo {
                    Id = 1, Descricao = "Artigo 1"
                });
                artigos.Add(new Artigo {
                    Id = 2, Descricao = "Artigo 2"
                });

                var linguagens = new List <LinguagemProgramacao>();
                linguagens.Add(new LinguagemProgramacao {
                    Nome = ".NET C#"
                });
                linguagens.Add(new LinguagemProgramacao {
                    Nome = "Python"
                });
                linguagens.Add(new LinguagemProgramacao {
                    Nome = "JAVA"
                });

                //throw new Exception("Opsss....deu erro!!");

                if (typeof(T) == typeof(Artigo))
                {
                    onSuccess((IEnumerable <T>)artigos);
                }
                if (typeof(T) == typeof(LinguagemProgramacao))
                {
                    onSuccess((IEnumerable <T>)linguagens);
                }
            }
            catch (Exception ex)
            {
                onError(new Erro($"Ocorreu um erro: { ex.Message }"));
            }
        }
Ejemplo n.º 24
0
        public static V ReadV(string fileUrl, OnErrorDelegate onError)
        {
            if (!File.Exists(fileUrl)) // File isn't exist.
            {
                onError?.Invoke(ErrorInfoManager.FILE_NOT_EXIST.Code, ErrorInfoManager.FILE_NOT_EXIST.Info);
                return(null);
            }
            string file = ReadFile(fileUrl, onError);

            Debug.WriteLine(file);
            try
            {
                V metro = JsonConvert.DeserializeObject <V>(file);
                return(metro);
            }
            catch (Exception e) // File isn't a valid json.
            {
                Debug.WriteLine(e);
                onError?.Invoke(ErrorInfoManager.JSON_NOT_VAILD.Code, ErrorInfoManager.JSON_NOT_VAILD.Info);
            }
            return(null);
        }
Ejemplo n.º 25
0
        public async Task UpdateNotes(PrivateEmailInfo emailInfo, string notes, OnErrorDelegate onErrorDelegate = null)
        {
            if (string.Equals(emailInfo.Notes, notes))
            {
                return;
            }

            if (notes == null)
            {
                notes = "";
            }

            OnWillExecute(this);

            try
            {
                await UpdateNotesRequest(emailInfo, notes, onErrorDelegate);
            }
            finally
            {
                OnDidExecute(this);
            }
        }
Ejemplo n.º 26
0
        public static void PreloadAsset(string _package, string _file
                                        , OnLoadReadyDelegate _onReady
                                        , OnLoadObjectSuccessDelegate _onSuccess
                                        , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }

            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            _onReady();
            string assetID = _package + "@" + _file;

            if (!preloadAssets.ContainsKey(assetID))
            {
                preloadAssets.Add(assetID, null);
                CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) =>
                {
                    Log.Debug("ResourceMgr", "load res [{0}] finish...", assetID);
                    preloadAssets[assetID] = _res;
                    _onSuccess(_res);
                },
                                                   _onError));
            }
            else
            {
                Log.Debug("ResourceMgr", "res [{0}] is exists...", assetID);
                _onSuccess(preloadAssets[assetID]);
            }
        }
Ejemplo n.º 27
0
 public static extern IntPtr GetClassObject(IntPtr module, string name, OnErrorDelegate onError, OnEventDelegate onEvent, OnStatusDelegate onStatus);
Ejemplo n.º 28
0
 public CompileErrorListener(OnErrorDelegate onError)
 {
     OnError = onError;
 }
Ejemplo n.º 29
0
 public CompileErrorListener(OnErrorDelegate onError)
 {
     OnError = onError;
 }
Ejemplo n.º 30
0
 private void StartInternal(BackupDataSource source, BackupDataSource destination, OnErrorDelegate onError)
 {
     try
     {
         this.Start(source, destination, null);
     }
     catch (Exception e)
     {
         // Pass the exception to the calling thread
         onError(e);
     }
 }
Ejemplo n.º 31
0
 public Quest RegisterErrorCallback(OnErrorDelegate callback)
 {
     this.OnError = callback;
     return(this);
 }
Ejemplo n.º 32
0
 private void StartInternal(BackupDataSource source, BackupDataSource destination, OnErrorDelegate onError)
 {
     try
     {
         this.Start(source, destination, null);
     }
     catch (Exception e)
     {
         // Pass the exception to the calling thread
         onError(e);
     }
 }