Exemplo n.º 1
0
        /// <summary>send call request to remote and pending callback
        /// </summary>
        /// <param name="remoteUri"></param>
        /// <param name="operation"></param>
        /// <param name="transportHeaders"></param>
        /// <param name="call"></param>
        /// <param name="callback"></param>
        public void Call(Uri remoteUri
            , ushort operation
            , IDictionary<string, object> transportHeaders
            , MethodCall call
            , RemotingCallback callback)
        {
            var data = this._serializationFactory.Get(callback.SerializationFormat).SerializeMethodCall(call);
            var flag = Interlocked.Increment(ref this._flag);
            callback.Flag = flag;
            transportHeaders.Add(RemotingTransportHeader.Flag, flag);
            transportHeaders.Add(RemotingTransportHeader.Format, callback.SerializationFormat);

            var request = new MemoryStream();
            var handle = new RemotingTcpProtocolHandle(request);
            handle.WritePreamble();
            handle.WriteMajorVersion();
            handle.WriteMinorVersion();
            handle.WriteOperation(TcpOperations.Request);
            handle.WriteContentDelimiter(TcpContentDelimiter.ContentLength);
            handle.WriteContentLength(data.Length);
            handle.WriteTransportHeaders(transportHeaders);
            handle.WriteContent(data);

            this.GetChannel(remoteUri).Send(request.ToArray());
            this._callbacks.Add(flag, callback);

            if (this._log.IsDebugEnabled)
                this._log.DebugFormat("pending methodCall#{0}|{1}", flag, remoteUri);
        }
Exemplo n.º 2
0
 /// <summary>cancel callback
 /// </summary>
 /// <param name="callback"></param>
 public void Cancel(RemotingCallback callback)
 {
     this._callbacks.Remove(callback.Flag);
 }