private void btnSlavesNew_Click(object sender, EventArgs e) { try { if (masterSocket == null) { masterSocket = new Socket.MasterSocket(CommonClasses.DefaultSettings.ListeningPort); } int idSlave; string IP = Microsoft.VisualBasic.Interaction.InputBox("insert IP", "", "192.168.1.50"); string sPort; do { sPort = Microsoft.VisualBasic.Interaction.InputBox("insert port", "", "" + CommonClasses.DefaultSettings.ListeningPort); } while (!sPort.All(char.IsDigit)); int port = Convert.ToInt32(sPort); string password = Microsoft.VisualBasic.Interaction.InputBox("insert password", "", CommonClasses.DefaultSettings.DefaultPassword); idSlave = masterSocket.AddNewSlave(IP, port, password); masterSocket.ConnectToSlave(idSlave); ListViewItem item = new ListViewItem("" + idSlave); item.SubItems.Add(IP); item.SubItems.Add("" + port); item.Tag = idSlave; //item.Text=IP + ":" + port; lsbSlaves.Items.Add(item); Hotkeys.HotKeyHelper.addHotKeySlave(idSlave); } catch (Exception exp) { MessageBox.Show("Impossibile stabilire una connessione"); } }
private void button6_Click(object sender, EventArgs e) { if (masterSocket == null) { masterSocket = new Socket.MasterSocket(CommonClasses.DefaultSettings.ListeningPort); } //idSlave= masterSocket.AddNewSlave("127.0.0.1"); string IP = Microsoft.VisualBasic.Interaction.InputBox("insert IP", "", "192.168.1.50"); idSlaveFocus = masterSocket.AddNewSlave(IP, CommonClasses.DefaultSettings.ListeningPort); masterSocket.ConnectToSlave(idSlaveFocus); Socket.MasterSocket.SlaveEnableDisable(idSlaveFocus, true); Hotkeys.HotKeyHelper.addHotKeySlave(idSlaveFocus); //idSlave = masterSocket.AddNewSlave("192.168.1.164"); //masterSocket.ConnectToSlave(idSlave); //new Thread(() => masterSocket.ConnectToSlave(idSlave)).Start(); }