Exemplo n.º 1
0
        internal CloseEventArgs(WebSocketSharp.PayloadData payloadData)
        {
            this._payloadData = payloadData;
            byte[] applicationData = payloadData.ApplicationData;
            int    length          = applicationData.Length;

            this._code   = (length <= 1) ? ((ushort)0x3ed) : applicationData.SubArray <byte>(0, 2).ToUInt16(ByteOrder.Big);
            this._reason = (length <= 2) ? string.Empty : applicationData.SubArray <byte>(2, (length - 2)).UTF8Decode();
        }
Exemplo n.º 2
0
        internal WebSocketFrame(WebSocketSharp.Fin fin, WebSocketSharp.Opcode opcode, WebSocketSharp.PayloadData payloadData, bool compressed, bool mask)
        {
            this._fin    = fin;
            this._rsv1   = (opcode.IsData() & compressed ? Rsv.On : Rsv.Off);
            this._rsv2   = Rsv.Off;
            this._rsv3   = Rsv.Off;
            this._opcode = opcode;
            ulong length = payloadData.Length;

            if (length < (long)126)
            {
                this._payloadLength    = (byte)length;
                this._extPayloadLength = WebSocket.EmptyBytes;
            }
            else if (length >= (long)65536)
            {
                this._payloadLength    = 127;
                this._extPayloadLength = length.InternalToByteArray(ByteOrder.Big);
            }
            else
            {
                this._payloadLength    = 126;
                this._extPayloadLength = ((ushort)length).InternalToByteArray(ByteOrder.Big);
            }
            if (!mask)
            {
                this._mask       = WebSocketSharp.Mask.Off;
                this._maskingKey = WebSocket.EmptyBytes;
            }
            else
            {
                this._mask       = WebSocketSharp.Mask.On;
                this._maskingKey = WebSocketFrame.createMaskingKey();
                payloadData.Mask(this._maskingKey);
            }
            this._payloadData = payloadData;
        }
Exemplo n.º 3
0
        internal WebSocketFrame(WebSocketSharp.Fin fin, WebSocketSharp.Opcode opcode, WebSocketSharp.PayloadData payloadData, bool compressed, bool mask)
        {
            this._fin    = fin;
            this._rsv1   = (!opcode.IsData() || !compressed) ? Rsv.Off : Rsv.On;
            this._rsv2   = Rsv.Off;
            this._rsv3   = Rsv.Off;
            this._opcode = opcode;
            ulong length = payloadData.Length;

            if (length < 0x7e)
            {
                this._payloadLength    = (byte)length;
                this._extPayloadLength = WebSocket.EmptyBytes;
            }
            else if (length < 0x10000L)
            {
                this._payloadLength    = 0x7e;
                this._extPayloadLength = ((ushort)length).InternalToByteArray(ByteOrder.Big);
            }
            else
            {
                this._payloadLength    = 0x7f;
                this._extPayloadLength = length.InternalToByteArray(ByteOrder.Big);
            }
            if (!mask)
            {
                this._mask       = WebSocketSharp.Mask.Off;
                this._maskingKey = WebSocket.EmptyBytes;
            }
            else
            {
                this._mask       = WebSocketSharp.Mask.On;
                this._maskingKey = createMaskingKey();
                payloadData.Mask(this._maskingKey);
            }
            this._payloadData = payloadData;
        }
Exemplo n.º 4
0
 internal CloseEventArgs()
 {
     this._code        = 0x3ed;
     this._payloadData = WebSocketSharp.PayloadData.Empty;
 }
Exemplo n.º 5
0
 internal static WebSocketFrame CreateCloseFrame(WebSocketSharp.PayloadData payloadData, bool mask)
 {
     return(new WebSocketFrame(WebSocketSharp.Fin.Final, WebSocketSharp.Opcode.Close, payloadData, false, mask));
 }
Exemplo n.º 6
0
 internal WebSocketFrame(WebSocketSharp.Opcode opcode, WebSocketSharp.PayloadData payloadData, bool mask) : this(WebSocketSharp.Fin.Final, opcode, payloadData, false, mask)
 {
 }
 internal CloseEventArgs(ushort code, string reason)
 {
     this._payloadData = new WebSocketSharp.PayloadData(code, reason);
 }
 internal CloseEventArgs(WebSocketSharp.PayloadData payloadData)
 {
     this._payloadData = payloadData;
 }