示例#1
0
 public static int ExtendedLength(byte[] xln, int snd)
 {
     if (snd == 126)
     {
         return(Bits.From2Bytes(xln));
     }
     if (snd == 127)
     {
         return((int)Bits.From8Bytes(xln));
     }
     else
     {
         return(snd);
     }
 }
示例#2
0
        public static WSFrame ClosePayload(WSFrame f)
        {
            if (f.Payload.Length == 0)
            {
                return(f);
            }
            if (f.Payload.Length == 1)
            {
                throw BadCloseLength;
            }

            var c = Bytes.From2Bytes(f.Payload.Take(2));

            if (!Ops.ValidCloseCodes.Contains(c))
            {
                throw BadCloseCode(c);
            }

            var valid = new Utf8Validation();
            var _     = valid.Add(f.Payload.Skip(2).ToArray()).Result;

            return(f);
        }