runtime.csharp.IRT.Transport.Client.ClientTransportCallback.cs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of idealingua-v1-runtime-rpc-c-sharp_2.13 Show documentation
Show all versions of idealingua-v1-runtime-rpc-c-sharp_2.13 Show documentation
idealingua-v1-runtime-rpc-c-sharp
The newest version!
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 => {});} }
}
}