Example #1
0
        private void MessageStoreOnMessageTimeout(object sender, MessageStoreEventArgs args)
        {
            var    idMsg = args.FailedMessage as IMqttIdMessage;
            string id    = idMsg == null ? "(no ID)" : idMsg.MessageId.ToString();

            Logger.LogMessage("Protocol", LogLevel.Verbose, "Message timeout: Type=" + args.FailedMessage.MessageType + ", QOS=" + args.FailedMessage.QualityOfService + ", ID=" + id);
            OnMessageTimeout(args);

            switch (args.FailedMessage.MessageType)
            {
            case MessageType.Connect:
                CloseConnection(args.ClientUid);
                FireConnectComplete(new MqttNetEventArgs
                {
                    Exception = new NotRespondingException("The remote MQTT device did not respond to a Connect request. The connection has been closed."),
                    Message   = args.FailedMessage,
                    EventData = args.EventData,
                    ClientUid = args.ClientUid
                });
                FireNetworkError(
                    args.FailedMessage,
                    new NotRespondingException("The remote MQTT device did not respond to a Connect request. The connection has been closed."));
                break;

            case MessageType.PingReq:
                CloseConnection(args.ClientUid);
                FireNetworkError(
                    args.FailedMessage,
                    new NotRespondingException("The remote MQTT device did not respond to a Ping request. The connection has been closed."));
                break;

            default:
                FireNetworkError(
                    args.FailedMessage,
                    new NotRespondingException("The remote MQTT device did not respond to a " +
                                               args.FailedMessage.MessageType + " message, ID=" + id + "."));
                break;
            }
        }
Example #2
0
 protected virtual void OnMessageTimeout(MessageStoreEventArgs args)
 {
 }