Skip to content

Instantly share code, notes, and snippets.

@joshmarinacci
Created December 3, 2015 06:12
Show Gist options
  • Save joshmarinacci/2840bec97edd3ecf9fb0 to your computer and use it in GitHub Desktop.
Save joshmarinacci/2840bec97edd3ecf9fb0 to your computer and use it in GitHub Desktop.
private void ReceivedMessageCallbackWhenSubscribed(string result)
{
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
{
List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result);
if (deserializedMessage != null && deserializedMessage.Count > 0)
{
object subscribedObject = (object)deserializedMessage[0];
if (subscribedObject != null)
{
string serializedResultMessage = pubnub.JsonPluggableLibrary.SerializeToJsonString(subscribedObject);
RTPMServer rtpmServer = JsonConvert.DeserializeObject<RTPMServer>(serializedResultMessage);
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
ctd = grid.RowDefinitions.Count;
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(columnHeight) });
TextBlock t = new TextBlock();
t.HorizontalAlignment = HorizontalAlignment.Left;
t.FontSize = 11;
t.Text = rtpmServer.Date.ToLocalTime().ToString();
t.SetValue(Grid.ColumnProperty, 0);
t.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(t);
TextBlock tS = new TextBlock();
tS.HorizontalAlignment = HorizontalAlignment.Left;
tS.FontSize = 12;
tS.Text = rtpmServer.ServerName;
tS.SetValue(Grid.ColumnProperty, 1);
tS.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tS);
TextBlock tC = new TextBlock();
tC.HorizontalAlignment = HorizontalAlignment.Center;
tC.FontSize = 14;
tC.Text = rtpmServer.CPUUsage.ToString("###.##") + " %";
tC.SetValue(Grid.ColumnProperty, 2);
tC.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tC);
TextBlock tR = new TextBlock();
tR.HorizontalAlignment = HorizontalAlignment.Center;
tR.FontSize = 14;
tR.Text = rtpmServer.RAMUsage.ToString() + " Mb";
tR.SetValue(Grid.ColumnProperty, 3);
tR.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tR);
ctd++;
}).GetResults();
}
}
}
mrePubNub.Set();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment