/// <summary> /// See interface docs. /// </summary> /// <returns></returns> public List <RebroadcastServerConnection> GetConnections() { var result = new List <RebroadcastServerConnection>(); if (Connector != null) { foreach (var connection in Connector.GetConnections().OfType <INetworkConnection>()) { var localEndPoint = connection.LocalEndPoint; var remoteEndPoint = connection.RemoteEndPoint; if (localEndPoint != null && remoteEndPoint != null) { var cookedConnection = new RebroadcastServerConnection() { BytesBuffered = connection.WriteQueueBytes, BytesWritten = connection.BytesWritten, EndpointIPAddress = remoteEndPoint == null ? null : remoteEndPoint.Address, EndpointPort = remoteEndPoint == null ? 0 : remoteEndPoint.Port, LocalPort = localEndPoint == null ? 0 : localEndPoint.Port, Name = Name, RebroadcastServerId = UniqueId, StaleBytesDiscarded = connection.StaleBytesDiscarded, }; result.Add(cookedConnection); } } } return(result); }
/// <summary> /// Updates the ListView item passed across to reflect the content of the connection. /// </summary> /// <param name="listItem"></param> /// <param name="connection"></param> private void UpdateListViewItem(ListViewItem listItem, RebroadcastServerConnection connection) { listItem.Tag = connection; while (listItem.SubItems.Count < 6) { listItem.SubItems.Add(""); } for (var i = 0; i < listItem.SubItems.Count; ++i) { var subItem = listItem.SubItems[i]; switch (i) { case 0: subItem.Text = connection.Name; break; case 1: subItem.Text = connection.EndpointIPAddress == null ? "" : String.Format("{0}:{1}", connection.EndpointIPAddress, connection.EndpointPort); break; case 2: subItem.Text = connection.LocalPort.ToString(); break; case 3: subItem.Text = connection.BytesBuffered.ToString("N0"); break; case 4: subItem.Text = connection.BytesWritten.ToString("N0"); break; case 5: subItem.Text = connection.StaleBytesDiscarded.ToString("N0"); break; } } }
public void RefreshFromRebroadcastServerConnection(RebroadcastServerConnection connection) { Id = connection.RebroadcastServerId; Name = connection.Name; LocalPort = connection.LocalPort; RemoteAddr = connection.RemoteAddress; RemotePort = connection.EndpointPort; Buffered = connection.BytesBuffered; Written = connection.BytesWritten; Discarded = connection.StaleBytesDiscarded; }
public RebroadcastServerConnectionModel(RebroadcastServerConnection connection) : this() { RefreshFromRebroadcastServerConnection(connection); }