All Downloads are FREE. Search and download functionalities are using the official Maven repository.

runtime.csharp.IRT.Transport.Client.ClientTransportCallback.cs Maven / Gradle / Ivy


using System;
using IRT.Transport;

namespace IRT.Transport.Client {
    public class ClientTransportCallback : IClientTransportCallback {
        public Action OnFailureHandler;
        public Action OnSuccessHandler;
        public Action FinalHandler;

        public ClientTransportCallback(Action onSuccess, Action onFailure, Action final = null) {
            OnSuccessHandler = onSuccess;
            OnFailureHandler = onFailure;
            FinalHandler = final;
        }

        public void Success(T result) {
            if (OnSuccessHandler != null) {
                OnSuccessHandler(result);
            }

            if (FinalHandler != null) {
                FinalHandler();
            }
        }

        public void Failure(TransportException exception) {
            if (OnFailureHandler != null) {
                OnFailureHandler(exception);
            }

            if (FinalHandler != null) {
                FinalHandler();
            }
        }

        public static ClientTransportCallback Empty { get {return new ClientTransportCallback(onSuccess => {}, onFailure => {});} }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy