internal static void UnwrapWebSocketBuffer(Interop.WebSocket.Buffer buffer,
WebSocketProtocolComponent.BufferType bufferType,
out IntPtr bufferData,
out uint bufferLength)
{
bufferData = IntPtr.Zero;
bufferLength = 0;
switch (bufferType)
{
case WebSocketProtocolComponent.BufferType.Close:
bufferData = buffer.CloseStatus.ReasonData;
bufferLength = buffer.CloseStatus.ReasonLength;
break;
case WebSocketProtocolComponent.BufferType.None:
case WebSocketProtocolComponent.BufferType.BinaryFragment:
case WebSocketProtocolComponent.BufferType.BinaryMessage:
case WebSocketProtocolComponent.BufferType.UTF8Fragment:
case WebSocketProtocolComponent.BufferType.UTF8Message:
case WebSocketProtocolComponent.BufferType.PingPong:
case WebSocketProtocolComponent.BufferType.UnsolicitedPong:
bufferData = buffer.Data.BufferData;
bufferLength = buffer.Data.BufferLength;
break;
default:
Debug.Assert(false,
string.Format(CultureInfo.InvariantCulture,
"BufferType '{0}' is invalid/unknown.",
bufferType));
break;
}
}