예제 #1
0
        /// <summary>
        /// When new connections from NetworkTraceListeners are accepted the method adds
        /// the new client to the connected client listview.
        /// </summary>
        /// <param name="sender">Sender of the message should be a NetworkAdapter</param>
        /// <param name="e">Parameters for the event. Containing the accepted connection</param>
        /// <remarks>
        /// Marshals the call to the gui thread an then adds the new client to the
        /// connectedclient listbox.
        /// </remarks>
        void Adapter_ConnectionAccepted(
            object sender,
            ESolutions.Net.ConnectionAcceptedEventArgs e)
        {
            if (InvokeRequired)
            {
                Delegate thisMethod = new ConnectionAcceptedEventHandler(Adapter_ConnectionAccepted);

                Invoke(thisMethod, new object[] { sender, e });
            }
            else
            {
                System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry(
                    e.Connection.FarEndPoint.Address);

                String[] itemStrings = new String[] {
                    entry.HostName,
                    e.Connection.FarEndPoint.ToString(),
                    DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToLongTimeString()
                };

                ListViewItem newItem = new ListViewItem(
                    itemStrings);

                newItem.Tag = e.Connection;

                this.connectedClientsListView.Items.Add(newItem);
            }
        }
예제 #2
0
 /// <summary>
 /// Fires the ConnectionAccepted event.
 /// </summary>
 protected void OnConnectionAccepted(Connection connection)
 {
     if (ConnectionAccepted != null)
     {
         ConnectionAcceptedEventArgs e = new ConnectionAcceptedEventArgs(connection);
         ConnectionAccepted(
             this,
             e);
     }
 }