#if !NET20 using System; using System.Collections.Generic; namespace Apewer.WebSocket { internal class ComposableHandler { public Func Handshake = s => new byte[0]; public Func TextFrame = x => new byte[0]; public Func BytesFrame = x => new byte[0]; public Action> ReceiveData = delegate { }; public Func PingFrame = i => new byte[0]; public Func PongFrame = i => new byte[0]; public Func CloseFrame = i => new byte[0]; private readonly List _data = new List(); public byte[] CreateHandshake(string subProtocol = null) { return Handshake(subProtocol); } public void Receive(IEnumerable data) { _data.AddRange(data); ReceiveData(_data); } public byte[] FrameText(string text) { return TextFrame(text); } public byte[] FrameBytes(byte[] bytes) { return BytesFrame(bytes); } public byte[] FramePing(byte[] bytes) { return PingFrame(bytes); } public byte[] FramePong(byte[] bytes) { return PongFrame(bytes); } public byte[] FrameClose(int code) { return CloseFrame(code); } } } #endif