using System.Text;
namespace Mirror.SimpleWeb
{
///
/// Constant values that should never change
///
/// Some values are from https://tools.ietf.org/html/rfc6455
///
///
internal static class Constants
{
///
/// Header is at most 4 bytes
///
/// If message is less than 125 then header is 2 bytes, else header is 4 bytes
///
///
public const int HeaderSize = 4;
///
/// Smallest size of header
///
/// If message is less than 125 then header is 2 bytes, else header is 4 bytes
///
///
public const int HeaderMinSize = 2;
///
/// bytes for short length
///
public const int ShortLength = 2;
///
/// Message mask is always 4 bytes
///
public const int MaskSize = 4;
///
/// Max size of a message for length to be 1 byte long
///
/// payload length between 0-125
///
///
public const int BytePayloadLength = 125;
///
/// if payload length is 126 when next 2 bytes will be the length
///
public const int UshortPayloadLength = 126;
///
/// if payload length is 127 when next 8 bytes will be the length
///
public const int UlongPayloadLength = 127;
///
/// Guid used for WebSocket Protocol
///
public const string HandshakeGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
public static readonly int HandshakeGUIDLength = HandshakeGUID.Length;
public static readonly byte[] HandshakeGUIDBytes = Encoding.ASCII.GetBytes(HandshakeGUID);
///
/// Handshake messages will end with \r\n\r\n
///
public static readonly byte[] endOfHandshake = new byte[4] { (byte)'\r', (byte)'\n', (byte)'\r', (byte)'\n' };
}
}