public static WsFrame Parse(Stream stream, bool unmask) { byte[] array = stream.ReadBytes(2); if (array.Length != 2) { throw new WebSocketException("The header part of a frame cannot be read from the data source."); } return(WsFrame.parse(array, stream, unmask)); }
public static void ParseAsync(Stream stream, bool unmask, Action <WsFrame> completed, Action <Exception> error) { stream.ReadBytesAsync(2, delegate(byte[] header) { if (header.Length != 2) { throw new WebSocketException("The header part of a frame cannot be read from the data source."); } WsFrame obj = WsFrame.parse(header, stream, unmask); if (completed != null) { completed(obj); } }, error); }