private void ReleaseResources() { _closeConnection(); _stream = null; if (_fragmentsBuffer != null) { _fragmentsBuffer.Dispose(); _fragmentsBuffer = null; InContinuation = false; } if (_receivePong != null) { _receivePong.Dispose(); _receivePong = null; } if (_exitReceiving == null) { return; } _exitReceiving.Dispose(); _exitReceiving = null; }
private async Task ProcessFragmentFrame(WebSocketFrame frame) { if (!InContinuation) { // Must process first fragment. if (frame.Opcode == Opcode.Cont) { return; } _fragmentsBuffer = new FragmentBuffer(frame.Opcode, frame.IsCompressed); InContinuation = true; } _fragmentsBuffer.AddPayload(frame.PayloadData.ApplicationData); if (frame.Fin == Fin.Final) { using (_fragmentsBuffer) { _messageEventQueue.Enqueue(await _fragmentsBuffer.GetMessage(Compression).ConfigureAwait(false)); } _fragmentsBuffer = null; InContinuation = false; } }