public Boolean Push(HttpListenerContext ListenerContext, String NewSessionId) { HttpReadContext PairContext = null; var Pushed = true; ReadContext.Update(c => { if (c != null) { if (c.ListenerContext != null) { Pushed = false; return(c); } else { c.ListenerContext = ListenerContext; c.NewSessionId = NewSessionId; PairContext = c; return(null); } } Pushed = true; return(new HttpReadContext { ListenerContext = ListenerContext, NewSessionId = NewSessionId, OnSuccess = null, OnFailure = null }); }); if (PairContext != null) { HandleRawRead(PairContext.ListenerContext, PairContext.NewSessionId, PairContext.OnSuccess, PairContext.OnFailure); } return(Pushed); }
private void OnStartRawRead(Action <HttpVirtualTransportServerHandleResult[]> OnSuccess, Action OnFailure) { HttpWriteContext PairWriteContext = null; WriteContext.Update(c => { if (c != null) { PairWriteContext = c; } return(null); }); if (PairWriteContext != null) { HandleRawWrite(PairWriteContext.ListenerContext, PairWriteContext.NewSessionId, PairWriteContext.Query); } HttpReadContext PairContext = null; var Pushed = true; ReadContext.Update(c => { if (c != null) { if (c.ListenerContext != null) { c.OnSuccess = OnSuccess; c.OnFailure = OnFailure; PairContext = c; Pushed = true; return(null); } else { Pushed = false; return(c); } } Pushed = true; return(new HttpReadContext { ListenerContext = null, NewSessionId = null, OnSuccess = OnSuccess, OnFailure = OnFailure }); }); if (PairContext != null) { HandleRawRead(PairContext.ListenerContext, PairContext.NewSessionId, PairContext.OnSuccess, PairContext.OnFailure); } if (!Pushed) { OnFailure(); } }
private void OnShutdownRead() { HttpReadContext PairContext = null; ReadContext.Update(c => { PairContext = c; return(null); }); if (PairContext != null) { if (PairContext.ListenerContext != null) { PairContext.ListenerContext.Response.StatusCode = 400; PairContext.ListenerContext.Response.Close(); } if (PairContext.OnFailure != null) { PairContext.OnFailure(); } } }