private void Request <T>(RpcRequest request, ICallback <T> callback) { Transceiver t = transceiver; if (!t.IsConnected) { Monitor.Enter(handshakeLock); handshakeThread = Thread.CurrentThread; try { if (!t.IsConnected) { var callFuture = new CallFuture <T>(callback); IList <MemoryStream> bytes = request.GetBytes(Local, this); var transceiverCallback = new TransceiverCallback <T>(this, request, callFuture, Local); t.Transceive(bytes, transceiverCallback); // Block until handshake complete callFuture.Wait(); Message message = GetMessage(request); if (message.Oneway.GetValueOrDefault()) { Exception error = callFuture.Error; if (error != null) { throw error; } } return; } } finally { if (Thread.CurrentThread == handshakeThread) { handshakeThread = null; Monitor.Exit(handshakeLock); } } } if (GetMessage(request).Oneway.GetValueOrDefault()) { t.LockChannel(); try { IList <MemoryStream> bytes = request.GetBytes(Local, this); t.WriteBuffers(bytes); if (callback != null) { callback.HandleResult(default(T)); } } finally { t.UnlockChannel(); } } else { IList <MemoryStream> bytes = request.GetBytes(Local, this); var transceiverCallback = new TransceiverCallback <T>(this, request, callback, Local); t.Transceive(bytes, transceiverCallback); //if (Thread.CurrentThread == handshakeThread) //{ // Monitor.Exit(handshakeLock); //} } }
// public void Request<TSpecificRecord, TCallback>(String messageName, Object request, ICallback<TCallback> callback) //where TCallback : class //where TSpecificRecord : class, ISpecificRecord public void Request <T>(String messageName, Object request, ICallback <T> callback) { var rpcRequest = new RpcRequest(messageName, request, new RpcContext()); Request(rpcRequest, callback); }
public Response(Requestor requestor, RpcRequest request, BinaryDecoder input) { this.requestor = requestor; this.request = request; this.input = input; }
private Message GetMessage(RpcRequest request) { return(request.GetMessage(Local)); }
public RpcRequest(RpcRequest request) : this(request.messageName, request.request, request.Context) { }