Exemple #1
0
        internal WebSocketFrame(
            Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask)
        {
            _fin    = fin;
            _rsv1   = opcode.IsData() && compressed ? Rsv.On : Rsv.Off;
            _rsv2   = Rsv.Off;
            _rsv3   = Rsv.Off;
            _opcode = opcode;

            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;
        }
Exemple #2
0
 internal WebSocketFrame(Opcode opcode, PayloadData payloadData, bool mask)
     : this(Fin.Final, opcode, payloadData, false, mask)
 {
 }
Exemple #3
0
 static PayloadData()
 {
     Empty     = new PayloadData();
     MaxLength = Int64.MaxValue;
 }
Exemple #4
0
 internal CloseEventArgs(ushort code, string reason)
 {
     _payloadData = new PayloadData(code, reason);
 }
Exemple #5
0
 internal CloseEventArgs(PayloadData payloadData)
 {
     _payloadData = payloadData;
 }
Exemple #6
0
 internal CloseEventArgs()
 {
     _payloadData = PayloadData.Empty;
 }