


using SuperSocket.SocketBase.Protocol;
using SuperWebSocket.SubProtocol;

namespace OCPPServer.SubProtocol
{
    public class OCPPSubCommandParser : IRequestInfoParser<SubRequestInfo>
    {
        #region ISubProtocolCommandParser Members

        /// <summary>
        /// Parses the request info.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public SubRequestInfo ParseRequestInfo(string source)
        {
            var cmd = source.Trim();
            int pos = cmd.IndexOf(',');
            string name;

            if (pos > 0)
            {
                name = cmd.Substring(pos - 1, 1);
            }
            else
            {
                name = "4";
            }

            return new SubRequestInfo(name, "", source);
        }

        #endregion ISubProtocolCommandParser Members
    }
}