ClientData.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 
  2. using EVCB_OCPP.Packet.Messages.Basic;
  3. using SuperSocket.SocketBase;
  4. using SuperWebSocket;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace OCPPServer.Protocol
  8. {
  9. public class ClientData : WebSocketSession<ClientData>
  10. { /// <summary>
  11. /// 根據unique id來儲存.取出OCPP Request
  12. /// </summary>
  13. public Queue queue = new Queue();
  14. public bool IsCheckIn { set; get; }
  15. public string ChargeBoxId { set; get; }
  16. public Guid CustomerId { get; set; }
  17. public string MachineId { set; get; }
  18. public string CustomerName { get; set; }
  19. public delegate void OCPPClientDataEventHandler<ClientData, String>(ClientData clientdata, String msg);
  20. public event OCPPClientDataEventHandler<ClientData, String> m_ReceiveData;
  21. public ClientData()
  22. {
  23. IsCheckIn = false;
  24. ChargeBoxId = SessionID;
  25. MachineId = SessionID;
  26. }
  27. /// <summary>
  28. /// Sends the raw binary data to client.
  29. /// </summary>
  30. /// <param name="data">The data.</param>
  31. /// <param name="offset">The offset.</param>
  32. /// <param name="length">The length.</param>
  33. public void SendRawData(byte[] data, int offset, int length)
  34. {
  35. base.Send(data, offset, length);
  36. }
  37. //receive data event trigger
  38. public void ReceiveData(ClientData clientdata, string msg)
  39. {
  40. if (m_ReceiveData != null)
  41. m_ReceiveData(clientdata, msg);
  42. }
  43. /// <summary>
  44. /// Called when [session closed].
  45. /// </summary>
  46. /// <param name="reason">The reason.</param>
  47. protected override void OnSessionClosed(CloseReason reason)
  48. {
  49. }
  50. }
  51. }