Beispiel #1
0
        public UCViewSingleGraph()
        {
            InitializeComponent();

            netChart.ChartAreas[0].AxisX.Maximum = GridlinesXMax;

            NetListener.NetRegister(this);
        }
Beispiel #2
0
 //注册消息监听
 public void AddMsgListener(NetListener nl)
 {
     if (al.Contains(nl))
     {
         return;
     }
     al.Add(nl);
 }
Beispiel #3
0
 private void button_listen_Click(object sender, EventArgs e)
 {
     if (button_listen.Text == "Listen")
     {
         NetListener.Start(int.Parse(textBox_port.Text));
         button_listen.Text = "Unlisten";
     }
     else
     {
         NetListener.Stop();
         button_listen.Text = "Listen";
     }
 }
        public void GetInterfaces_Test()
        {
            NetListener.AdapterList.GetFirstUpInterface();

            CurrentInterface = NetListener.AdapterList.SelectedItem;

            Assert.IsNotNull(CurrentInterface);

            NetListener.Start();

            Assert.IsTrue(CurrentInterface.State.Up);

            Assert.AreEqual(CurrentInterface.State.Text, "Up");
        }
Beispiel #5
0
        /// <summary>
        /// Shows the options for this application. The OptionsForm defines what
        /// options are available, and exports them in a public structure.
        /// </summary>
        /// <param name="sender">The sender of this event.</param>
        /// <param name="e">The arguments for this event.</param>
        private void mniTestOptions_Click(object sender, EventArgs e)
        {
            OptionsForm dlg = new OptionsForm(_o);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                // stop any sending or listening
                if (_sender != null && _sender.IsConnected)
                {
                    _sender.Disconnect();
                }
                if (_listener != null && _listener.IsListening)
                {
                    _listener.Stop();
                }

                // set our options reference
                _o = dlg.Settings;

                // potentially start receiving as a network server
                if (_o.ReceiveOnNet)
                {
                    if (_o.UseWebSockets)
                    {
                        _listener = new WebSocketListener(this); // ws
                    }
                    else
                    {
                        _listener = new NetListener(this); // tcp
                    }
                    _listener.NetDataEvent += new NetListener.NetEventHandler(OnNetworkDataReceived);

                    _listener.IP   = _o.ReceiveIP;
                    _listener.Port = _o.ReceivePort;
                    _listener.Start();
                }

                // potentially start sending as a network client
                if (_o.SendOnTcp)
                {
                    _sender      = new NetSender();
                    _sender.IP   = _o.SendIP;
                    _sender.Port = _o.SendPort;
                    _sender.Connect();
                }
            }
        }
Beispiel #6
0
        public UCViewList()
        {
            InitializeComponent();

            dataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            dataGrid.DefaultCellStyle.SelectionForeColor = dataGrid.DefaultCellStyle.ForeColor;
            dataGrid.DefaultCellStyle.SelectionBackColor = dataGrid.DefaultCellStyle.BackColor;

            data            = new BindingSource();
            data.DataSource = NetListener.AdapterList;
            dataGrid.AutoGenerateColumns = false;
            dataGrid.DataSource          = null;
            dataGrid.DataSource          = data;
            dataGrid.Refresh();
            NetListener.NetRegister(this);
        }
Beispiel #7
0
        private void OContextMenuStartStop_Click(object sender, EventArgs e)
        {
            if (sender is ToolStripItem o)
            {
                o.Enabled = false;

                switch (o.Text)
                {
                case "Start":
                    NetListener.Start();
                    oContextMenuStop.Enabled = true;
                    break;

                default:
                    NetListener.Stop();
                    oContextMenuStart.Enabled = true;
                    break;
                }
            }
        }
Beispiel #8
0
        public static void ReloadNetwork_Click(object sender, EventArgs e)
        {
            if (sender is ToolStripItem oItem)
            {
                ToolStripMenuItem[] oMenus = (oItem.Tag as ToolStripMenuItem[]);

                if (oMenus != null)
                {
                    NetListener.Stop();

                    NetListener.AdapterList.UpdateList();

                    foreach (ToolStripMenuItem oMenu in oMenus)
                    {
                        SetMenuInterfaces(oMenu);
                    }

                    NetListener.AdapterList.GetFirstUpInterface();

                    NetListener.Start();
                }
            }
        }
Beispiel #9
0
 public Test_Observer()
 {
     NetListener.NetRegister(this);
 }
 public MatchInfo(NetListener subject)
 {
     this.subject = subject;
     this.subject.RegisterObserver(this);
 }
Beispiel #11
0
        public UCViewMini()
        {
            InitializeComponent();

            NetListener.NetRegister(this);
        }
Beispiel #12
0
 public NetManager()
 {
     mConnectionList = new Dictionary<long, NetConnection>();
     mNetListener = new NetListener(new NetListener.NewConnectionDelegate(NewConnection));
 }