DataChannelGraphView.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine.UIElements;
  2. namespace Unity.WebRTC.Editor
  3. {
  4. internal class DataChannelGraphView
  5. {
  6. private GraphView messageSentGraph = new GraphView("messageSent");
  7. private GraphView bytesSentGraph = new GraphView("bytesSent");
  8. private GraphView messageReceivedGraph = new GraphView("messageReceived");
  9. private GraphView bytesReceivedGraph = new GraphView("bytesReceived");
  10. public void AddInput(RTCDataChannelStats input)
  11. {
  12. var timestamp = input.UtcTimeStamp;
  13. messageSentGraph.AddInput(timestamp, input.messagesSent);
  14. bytesSentGraph.AddInput(timestamp, input.bytesSent);
  15. messageReceivedGraph.AddInput(timestamp, input.messagesReceived);
  16. bytesReceivedGraph.AddInput(timestamp, input.bytesReceived);
  17. }
  18. public VisualElement Create()
  19. {
  20. var container = new VisualElement {style = {flexDirection = FlexDirection.Row, flexWrap = Wrap.Wrap}};
  21. container.Add(messageReceivedGraph.Create());
  22. container.Add(bytesSentGraph.Create());
  23. container.Add(messageReceivedGraph.Create());
  24. container.Add(bytesReceivedGraph.Create());
  25. return container;
  26. }
  27. }
  28. }