//internal WebSocketFrame(string textMessage) // :this() public WebSocketFrame(Fin fin, Opcode opcode, PayLoadData payLoadData, bool mask = false) { Fin = fin; Rsv2 = Rsv.Off; Rsv3 = Rsv.Off; Rsv4 = Rsv.Off; Opcode = opcode; var len = payLoadData.Length; if (len < 126) { PayloadLength = (byte)len; ExtendedPayloadLength = new byte[0]; } else if (len < 65536) { PayloadLength = 126; ExtendedPayloadLength = ((ushort)len).InternalToByteArray(ByteOrder.Big); } else { PayloadLength = 127; ExtendedPayloadLength = len.InternalToByteArray(ByteOrder.Big); } if (mask) { Mask = Mask.On; } else { Mask = Mask.Off; MaskingKey = new byte[0]; } PayloadData = payLoadData; }
static PayLoadData() { Empty = new PayLoadData(); MaxLength = Int64.MaxValue; }
internal static WebSocketFrame CreateCloseFrame(PayLoadData payLoadData, bool mask) { return(new WebSocketFrame(Fin.Final, Opcode.Close, payLoadData, false)); }