internal void Unmask() { if (_mask == Mask.Off) { return; } _mask = Mask.Off; _payloadData.Mask(_maskingKey); _maskingKey = WebSocket.EmptyBytes; }
internal WebSocketFrame( Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask ) { _fin = fin; _opcode = opcode; _rsv1 = opcode.IsData() && compressed ? Rsv.On : Rsv.Off; _rsv2 = Rsv.Off; _rsv3 = Rsv.Off; var len = payloadData.Length; if (len < 126) { _payloadLength = (byte)len; _extPayloadLength = WebSocket.EmptyBytes; } else if (len < 0x010000) { _payloadLength = (byte)126; _extPayloadLength = ((ushort)len).InternalToByteArray(ByteOrder.Big); } else { _payloadLength = (byte)127; _extPayloadLength = len.InternalToByteArray(ByteOrder.Big); } if (mask) { _mask = Mask.On; _maskingKey = createMaskingKey(); payloadData.Mask(_maskingKey); } else { _mask = Mask.Off; _maskingKey = WebSocket.EmptyBytes; } _payloadData = payloadData; }