public void ProcessFrame(Frame frame) { // Add frame to the list of history Frames.Add (frame); if (frame.Type == FrameType.RstStream || frame.IsEndStream || frame.Type == FrameType.GoAway) { State = StreamState.Closed; } else { if (State == StreamState.Idle) { if (frame.Type == FrameType.Headers) { State = StreamState.Open; } } if (frame.Type == FrameType.PushPromise && State == StreamState.Idle) { State = StreamState.ReservedRemote; } } // Raise the event var eh = OnFrameReceived; if (eh != null) eh(frame); }
public async Task SendFrame (Frame frame) { var data = frame.ToBytes ().ToArray (); await lockWrite.WaitAsync (); try { await clientStream.WriteAsync(data, 0, data.Length); await clientStream.FlushAsync(); } catch { } finally { lockWrite.Release(); } }