Beispiel #1
0
      /// <summary>
      /// Fill the Info object with data from the given JsonMessage.
      /// </summary>
      /// <param name="message">Message object containing JSON value and meta-data.</param>
      internal override void Fill(JsonMessage message)
      {
         Debug.Assert(message != null);

         var propertySetter = new MessagePropertySetter(this);
         foreach (var token in JArray.Parse(message.Value.ToString()))
         {
            if (!token.HasValues)
            {
               continue;
            }

            object clientInfoProperty = propertySetter.GetPropertyValue((string)token[0]);
            if (clientInfoProperty != null)
            {
               var innerPropertySetter = new MessagePropertySetter(clientInfoProperty);
               foreach (var innerToken in token)
               {
                  if (!innerToken.HasValues)
                  {
                     continue;
                  }

                  if (innerToken.Values().Count() >= 2)
                  {
                     innerPropertySetter.SetProperty((string)innerToken[0], (string)innerToken[1]);
                  }
               }
            }
         }
         SetMessageValues(message);
      }      
Beispiel #2
0
 /// <summary>
 /// Fill the LogFragment object with data from the given JsonMessage.
 /// </summary>
 /// <param name="message">Message object containing JSON value and meta-data.</param>
 public override void Fill(JsonMessage message)
 {
    Debug.Assert(message != null);
    message.Value.CopyTo(Value);
    int startIndex = GetStartIndex(Value);
    int length = (Value.EndsWith('\"') ? Value.Length - 1 : Value.Length) - startIndex;
    SetEnvironmentNewLineCharacters(Value.SubstringBuilder(startIndex, length, true));
    SetMessageValues(message);
 }
Beispiel #3
0
      #pragma warning restore 1591

      #endregion

      /// <summary>
      /// Fill the Options object with data from the given JsonMessage.
      /// </summary>
      /// <param name="message">Message object containing JSON value and meta-data.</param>
      internal override void Fill(JsonMessage message)
      {
         Debug.Assert(message != null);

         var propertySetter = new MessagePropertySetter(this);
         foreach (var prop in JObject.Parse(message.Value.ToString()).Properties())
         {
            propertySetter.SetProperty(prop);
         }
         SetMessageValues(message);
      }
Beispiel #4
0
 /// <summary>
 /// Fill the Heartbeat object with data from the given JsonMessage.
 /// </summary>
 /// <param name="message">Message object containing JSON value and meta-data.</param>
 internal override void Fill(JsonMessage message)
 {
     Debug.Assert(message != null);
      Value = Int32.Parse(message.Value.ToString(), CultureInfo.InvariantCulture);
      SetMessageValues(message);
 }
Beispiel #5
0
      #pragma warning restore 1591

      #endregion

      /// <summary>
      /// Fill the SimulationInfo object with data from the given JsonMessage.
      /// </summary>
      /// <param name="message">Message object containing JSON value and meta-data.</param>
      public override void Fill(JsonMessage message)
      {
         Debug.Assert(message != null);

         JObject jObject;
         using (var reader = (JsonReader)new JsonTextReader(new StringReader(message.Value.ToString())))
         {
            reader.DateParseHandling = DateParseHandling.None;
            jObject = JObject.Load(reader);
         }

         var propertySetter = new MessagePropertySetter(this);
         foreach (var prop in jObject.Properties())
         {
            propertySetter.SetProperty(prop);
         }
         SetMessageValues(message);
      }
Beispiel #6
0
 private void UpdateMessageCache(JsonMessage message)
 {
     _messages[message.Key] = message;
      OnStatusMessage(new StatusMessageEventArgs(String.Format(CultureInfo.CurrentCulture,
     "Received message: {0} ({1} bytes)", message.Key, message.Value.Length), TraceLevel.Info));
 }
Beispiel #7
0
 public abstract void Fill(JsonMessage message);
Beispiel #8
0
        /// <summary>
        /// Parse first message from the data buffer and remove it from the buffer value.  The remaining buffer value is returned to the caller.
        /// </summary>
        /// <param name="buffer">Data buffer value.</param>
        /// <returns>JsonMessage or null if no message is available in the buffer.</returns>
        internal static JsonMessage GetNextJsonMessage(StringBuilder buffer)
        {
            if (buffer == null) return null;

             // find the header
             int messageIndex = buffer.IndexOf(PyonHeader, false);
             if (messageIndex < 0)
             {
            return null;
             }
             // set starting message index
             messageIndex += PyonHeader.Length;

             // find the first CrLf or Lf character after the header
             int startIndex = FindStartIndex(buffer, messageIndex);
             if (startIndex < 0) return null;

             // find the footer
             int endIndex = FindEndIndex(buffer, startIndex);
             if (endIndex < 0)
             {
            return null;
             }

             // create the message and set received time stamp
             var message = new JsonMessage { Received = DateTime.UtcNow };
             // get the message name
             message.Key = buffer.Substring(messageIndex, startIndex - messageIndex);

             // get the PyON message
             buffer.SubstringBuilder(startIndex, message.Value, endIndex - startIndex);
             // replace PyON values with JSON values
             message.Value.Replace(": None", ": null");

             // set the index so we know where to trim the string (end plus footer length)
             int nextStartIndex = endIndex + PyonFooter.Length;
             // if more buffer is available set it and return, otherwise set the buffer empty
             if (nextStartIndex < buffer.Length)
             {
            buffer.Remove(0, nextStartIndex);
             }
             else
             {
            buffer.Clear();
             }

             return message;
        }
Beispiel #9
0
 internal abstract void Fill(JsonMessage message);
Beispiel #10
0
 internal abstract void Fill <T>(JsonMessage message) where T : ITypedMessageObject;
Beispiel #11
0
 public abstract void Fill(JsonMessage message);
Beispiel #12
0
 /// <summary>
 /// Fill the SlotCollection object with data from the given JsonMessage.
 /// </summary>
 /// <param name="message">Message object containing JSON value and meta-data.</param>
 internal override void Fill(JsonMessage message)
 {
     Fill <Slot>(message);
 }
 /// <summary>
 /// Initializes a new instance of the MessageUpdatedEventArgs class.
 /// </summary>
 /// <param name="jsonMessage">The JSON message.</param>
 public MessageReceivedEventArgs(JsonMessage jsonMessage)
 {
    JsonMessage = jsonMessage;
 }