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); }
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); }
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); } }
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); } }
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); } }
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; }