Beispiel #1
0
        public Task StartNew(MqttCommand command, Action <MqttCommand> onSuccess)
        {
            switch (command.CommandMessage)
            {
            case CommandMessage.CONNECT:
                var connFlow = new ConnectReceiveFlow(this);
                return(connFlow.Start(command, onSuccess));

            case CommandMessage.PUBLISH:
                var pubFlow = new PublishReceiveFlow(this);
                return(pubFlow.Start(command, onSuccess));

            case CommandMessage.SUBSCRIBE:
                var subFlow = new SubscribeFlow(this);
                return(subFlow.Start(command, onSuccess));

            case CommandMessage.PINGREQ:
                var pingFlow = new PingSendFlow(this);
                return(pingFlow.Start(command, onSuccess));

            default:
                var tcs = new TaskCompletionSource <object>();
                tcs.SetException(new InvalidOperationException("Unhandled command type"));
                return(tcs.Task);
            }
        }
Beispiel #2
0
 public Task StartNew(MqttCommand command, Action<MqttCommand> onSuccess)
 {
     switch (command.CommandMessage)
     {
         case CommandMessage.CONNECT:
             var connFlow = new ConnectReceiveFlow(this);
             return connFlow.Start(command, onSuccess);
         case CommandMessage.PUBLISH:
             var pubFlow = new PublishReceiveFlow(this);
             return pubFlow.Start(command, onSuccess);
         case CommandMessage.SUBSCRIBE:
             var subFlow = new SubscribeFlow(this);
             return subFlow.Start(command, onSuccess);
         case CommandMessage.PINGREQ:
             var pingFlow = new PingSendFlow(this);
             return pingFlow.Start(command, onSuccess);
         default:
             var tcs = new TaskCompletionSource<object>();
             tcs.SetException(new InvalidOperationException("Unhandled command type"));
             return tcs.Task;
     }
 }