Beispiel #1
0
 public OcppMessage(MessageType messageType, Guid messageId, string payload, OcppAction action = OcppAction.Unknown) //, string name = null)
 {
     MessageType = messageType;
     MessageId   = messageId;
     Payload     = payload;
     Action      = action;
 }
Beispiel #2
0
        public OcppMessage(ArraySegment <byte> message)
        {
            JsonSerializerOptions options = GetSerializerOptions();

            var responseArray = JsonSerializer.Deserialize <object[]>(message, options);

            MessageType = (MessageType)int.Parse(responseArray[0].ToString());
            MessageId   = Guid.Parse(responseArray[1].ToString());

            if (!Enum.TryParse <OcppAction>(responseArray[2].ToString(), out OcppAction action))
            {
                action = OcppAction.Unknown;
            }

            if (responseArray.Length == 4)
            {
                Action  = action;
                Payload = responseArray[3].ToString();
            }
            else
            {
                Payload = responseArray[2].ToString();
            }
        }