コード例 #1
0
        public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
        {
            HandshakeMessage message = GetMessage(handshakeType);

            message.Process();
            SendRecordAsyncResult sendRecordAsyncResult = new SendRecordAsyncResult(callback, state, message);

            BeginSendRecord(message.ContentType, message.EncodeMessage(), InternalSendRecordCallback, sendRecordAsyncResult);
            return(sendRecordAsyncResult);
        }
コード例 #2
0
        public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
        {
            HandshakeMessage msg = this.GetMessage(handshakeType);

            msg.Process();

            DebugHelper.WriteLine(">>>> Write handshake record ({0}|{1})", context.Protocol, msg.ContentType);

            SendRecordAsyncResult internalResult = new SendRecordAsyncResult(callback, state, msg);

            this.BeginSendRecord(msg.ContentType, msg.EncodeMessage(), new AsyncCallback(InternalSendRecordCallback), internalResult);

            return(internalResult);
        }
コード例 #3
0
        private void InternalSendRecordCallback(IAsyncResult ar)
        {
            SendRecordAsyncResult sendRecordAsyncResult = ar.AsyncState as SendRecordAsyncResult;

            try
            {
                EndSendRecord(ar);
                sendRecordAsyncResult.Message.Update();
                sendRecordAsyncResult.Message.Reset();
                sendRecordAsyncResult.SetComplete();
            }
            catch (Exception complete)
            {
                sendRecordAsyncResult.SetComplete(complete);
            }
        }
コード例 #4
0
 public void EndSendRecord(IAsyncResult asyncResult)
 {
     if (asyncResult is SendRecordAsyncResult)
     {
         SendRecordAsyncResult internalResult = asyncResult as SendRecordAsyncResult;
         if (!internalResult.IsCompleted)
         {
             internalResult.AsyncWaitHandle.WaitOne();
         }
         if (internalResult.CompletedWithError)
         {
             throw internalResult.AsyncException;
         }
     }
     else
     {
         this.innerStream.EndWrite(asyncResult);
     }
 }
コード例 #5
0
        private void InternalSendRecordCallback(IAsyncResult ar)
        {
            SendRecordAsyncResult internalResult = ar.AsyncState as SendRecordAsyncResult;

            try
            {
                this.EndSendRecord(ar);

                // Update session
                internalResult.Message.Update();

                // Reset message contents
                internalResult.Message.Reset();

                internalResult.SetComplete();
            }
            catch (Exception ex)
            {
                internalResult.SetComplete(ex);
            }
        }
コード例 #6
0
		public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
		{
			HandshakeMessage msg = this.GetMessage(handshakeType);

			msg.Process();

			DebugHelper.WriteLine(">>>> Write handshake record ({0}|{1})", context.Protocol, msg.ContentType);

			SendRecordAsyncResult internalResult = new SendRecordAsyncResult(callback, state, msg);

			this.BeginSendRecord(msg.ContentType, msg.EncodeMessage(), new AsyncCallback(InternalSendRecordCallback), internalResult);

			return internalResult;
		}