Beispiel #1
0
        private void OnConnDisconnected(int connId, object sender, MqttClientDisconnectedEventArgs args)
        {
            if (_connection != null && _connection.Id != connId)
            {
                FizzLogger.W("Received disconnected event for old connection.");
            }

            FizzLogger.D("MQTT - OnDisconnected: " + args.ClientWasConnected.ToString());

            if (OnDisconnected != null)
            {
                if (args.Exception == null)
                {
                    OnDisconnected.Invoke(null);
                }
                else
                {
                    if (args.Exception.GetType() == typeof(MQTTnet.Adapter.MqttConnectingFailedException))
                    {
                        OnDisconnected.Invoke(ERROR_AUTH_FAILED);
                        if (_sessionRepo != null)
                        {
                            _sessionRepo.FetchToken(null);
                        }
                    }
                    else
                    {
                        OnDisconnected.Invoke(ERROR_CONNECTION_FAILED);
                    }
                }
            }
        }
        private void OnConnDisconnected(object sender, FizzMqttDisconnectedArgs args)
        {
            FizzLogger.D("MQTT - OnDisconnected: " + args.ClientWasConnected.ToString());

            if (OnDisconnected != null)
            {
                if (args.Exception == null)
                {
                    OnDisconnected.Invoke(null);
                }
                else
                {
                    if (args.Exception.GetType() == typeof(FizzMqttAuthException))
                    {
                        OnDisconnected.Invoke(ERROR_AUTH_FAILED);
                        if (_sessionRepo != null)
                        {
                            _sessionRepo.FetchToken(null);
                        }
                    }
                    else
                    {
                        OnDisconnected.Invoke(ERROR_CONNECTION_FAILED);
                    }
                }
            }

            if (_closeCallback != null)
            {
                FizzUtils.DoCallback(_closeCallback);
            }
        }