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