/// <summary> /// 取得目前所有有效連線 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_GetAllClients_Click(object sender, EventArgs e) { checkedListBox_Clients.Items.Clear(); fAvailableClients = fProxyServer.GetAvailableClinets(); foreach (var client in fAvailableClients) { checkedListBox_Clients.Items.Add(client.Address, false); } }
public MainForm() { InitializeComponent(); fSetting = new Settings(); MarketType marketType = (MarketType)fSetting.ApMartketType; this.Text = string.Format("{0} {1} Ver:{2} x{3}", marketType, Application.ProductName, Application.ProductVersion, IntPtr.Size * 8); //服務原始IDKey string originKey = string.Format("{0}:{1}", Dpsc.GetServiceOriginalKey(fSetting.DpscPort, Assembly.GetExecutingAssembly()), marketType); TextBox_DpscKeyId.Text = originKey; // dataGridView 錯誤處理 (不然會跳exception) DataGridView_Clients.DataError += DataGridView_Clients_DataError; fProxyServer = new ProxyServer(fSetting.MulticastPort, fSetting.IsKeepNewConnectionWhenOverLimit, fSetting.ClientHeartBeatFrequency, fSetting.ClientSameIPLimitCount, OutMessages); fProxyServer.OnStatus.OnFireEvent += fProxyServer_OnStatusMessage; // 心跳封包樣本 fHeartbeat = new Heartbeat(new TimeSpan(0, 0, fSetting.HeartBeatFrequency), fProxyServer.Broadcasting); fProxyServer.SetHeartBeatPackage(fHeartbeat.HeartbeatBytes, Heartbeat.HEART_BEAT_DATA_TYPE); //發送模組 fForwardModule = new ForwardModule(originKey, fSetting.DpscIp, fSetting.DpscPort, fSetting.DpscChk, OutMessages, fHeartbeat.BlockingHeartbeat, fSetting.RawDataChannel ); // datagrid綁資料結構 fBindingSource = new BindingSource(); fBindingSource.DataSource = fProxyServer.GetAvailableClinets(); DataGridView_Clients.DataSource = fBindingSource; }