OCPPSubCommandParser.cs 894 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 
  2. using SuperSocket.SocketBase.Protocol;
  3. using SuperWebSocket.SubProtocol;
  4. namespace OCPPServer.SubProtocol
  5. {
  6. public class OCPPSubCommandParser : IRequestInfoParser<SubRequestInfo>
  7. {
  8. #region ISubProtocolCommandParser Members
  9. /// <summary>
  10. /// Parses the request info.
  11. /// </summary>
  12. /// <param name="source">The source.</param>
  13. /// <returns></returns>
  14. public SubRequestInfo ParseRequestInfo(string source)
  15. {
  16. var cmd = source.Trim();
  17. int pos = cmd.IndexOf(',');
  18. string name;
  19. if (pos > 0)
  20. {
  21. name = cmd.Substring(pos - 1, 1);
  22. }
  23. else
  24. {
  25. name = "4";
  26. }
  27. return new SubRequestInfo(name, "", source);
  28. }
  29. #endregion ISubProtocolCommandParser Members
  30. }
  31. }