Example #1
0
		private static void Unmask(byte[] message)
		{
			var wsHeader = new WebSocketHeader()
			{
				Mask = true,
				MaskingKey0 = 0x12,
				MaskingKey1 = 0x34,
				MaskingKey2 = 0x56,
				MaskingKey3 = 0x78,
			};

			wsHeader.MaskData(message, 0, message.Length);
		}
Example #2
0
		private static byte[] PrepareForWebsocket(byte[] message, Opcodes opcode)
		{
			var wsHeader = new WebSocketHeader()
			{
				Fin = true,
				Opcode = opcode,
				PayloadLength = message.Length,
				Mask = true,
				MaskingKey0 = 0x12,
				MaskingKey1 = 0x34,
				MaskingKey2 = 0x56,
				MaskingKey3 = 0x78,
			};

			var extra = new byte[wsHeader.GetHeaderLength()];
			wsHeader.GenerateHeader(new ArraySegment<byte>(extra));

			if (wsHeader.Mask)
				wsHeader.MaskData(message, 0, message.Length);

			return extra;
		}