OCPPSubCommandConverter.cs 891 B

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