コード例 #1
0
ファイル: Runtime.cs プロジェクト: umu24013/Chat
        private void OnEvent(BackendEvent newEvent)
        {
            if (newEvent is BackendEventError)
            {
                var error = newEvent as BackendEventError;

                if (error.Policy == ErrorPolicyType.Deactivate)
                {
                    try
                    {
                        var accounts = new Accounts();
                        var account  = accounts[error.Id];
                        if (account != null)
                        {
                            account.persistantState = AccountState.Disabled;
                            account.forceDisabled   = true;
                        }
                    }
                    catch { }
                }
            }

            if (_notifier != null)
            {
                // Returns true if user relevant
                if (_notifier.Push(newEvent))
                {
                    newEvent.Persist = true;
                }
            }

            _events.Enqueue(newEvent);
        }
コード例 #2
0
        private void OnProcessBackendEvent()
        {
            try
            {
                if (_blocked)
                {
                    _newRequest = true;
                }
                else
                {
                    _blocked = true;
                    {
                        BackendEvent newEvent = null;

                        do
                        {
                            newEvent = GetBackendEvent();

                            if (newEvent == null)
                            {
                                break;
                            }

                            if (newEvent is BackendEventWindows)
                            {
                                OnBackendEventWindows(newEvent as BackendEventWindows);
                            }
                            if (newEvent is BackendEventMessage)
                            {
                                OnBackendEventMessage(newEvent as BackendEventMessage);
                            }
                            if (newEvent is BackendEventRequest)
                            {
                                OnBackendEventRequest(newEvent as BackendEventRequest);
                            }
                            if (newEvent is BackendEventState)
                            {
                                OnBackendEventState(newEvent as BackendEventState);
                            }
                            if (newEvent is BackendEventLog)
                            {
                                OnBackendEventLog(newEvent as BackendEventLog);
                            }
                            if (newEvent is BackendEventError)
                            {
                                OnBackendEventError(newEvent as BackendEventError);
                            }
                        }while (newEvent != null);
                    }
                    _blocked = false;

                    if (_newRequest)
                    {
                        _newRequest = false;
                        OnProcessBackendEvent();
                    }
                }
            }
            catch (Exception uiEx) { UIError(uiEx); }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: MONICA-Project/ttn-bridge
 private async void TTNTrackerMessageIncomming(Object _1, BackendEvent e) => await Task.Run(() => {
     Tuple <String, String> json = this.ConvertTrackerJson(e.Message);
     if (json != null)
     {
         this.mqtt.Send(json.Item1, json.Item2);
         Console.WriteLine("Mqtt ->: on " + json.Item1 + " set " + json.Item2);
     }
 });
コード例 #4
0
ファイル: Server.cs プロジェクト: MONICA-Project/lora-map
 protected override void Backend_MessageIncomming(Object sender, BackendEvent mqtt)
 {
     try {
         JsonData d = JsonMapper.ToObject(mqtt.Message);
         PositionModel.Instance.ParseMqttJson(d, (String)mqtt.From);
         CameraModel.Instance.ParseMqttJson(d, (String)mqtt.From);
         SensorModel.Instance.ParseMqttJson(d, (String)mqtt.From);
     } catch (Exception e) {
         Helper.WriteError("Backend_MessageIncomming(): " + e.Message + "\n\n" + e.StackTrace);
     }
 }