Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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;
                }
            }
        }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 public RebroadcastServerConnectionModel(RebroadcastServerConnection connection) : this()
 {
     RefreshFromRebroadcastServerConnection(connection);
 }