using System; using System.Collections.Generic; using System.Linq; using System.Text; using SuperSocket.SocketBase.Command; using SuperWebSocket.Protocol; namespace SuperWebSocket.Command { /// /// The command handling binary data /// /// The type of the web socket session. class Binary : FragmentCommand where TWebSocketSession : WebSocketSession, new() { /// /// Gets the name. /// public override string Name { get { return OpCode.BinaryTag; } } /// /// Executes the command. /// /// The session. /// The request info. public override void ExecuteCommand(TWebSocketSession session, IWebSocketFragment requestInfo) { var frame = requestInfo as WebSocketDataFrame; if (!CheckFrame(frame)) { session.Close(); return; } if (frame.FIN) { if (session.Frames.Count > 0) { session.Close(); return; } var data = GetWebSocketData(frame); session.AppServer.OnNewDataReceived(session, data); } else { session.Frames.Add(frame); } } } }