private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; if (this.server == null || enableListeningModeToolStripMenuItem.Checked == false) { timer1.Enabled = true; return; } timer1.Enabled = false; if (this.server.Pending()) { System.Net.IPEndPoint ep; TcpClient client = server.AcceptTcpClient(); ep = (System.Net.IPEndPoint)client.Client.RemoteEndPoint; AubitNetwork an; AppWin = new frmMainAppWindow(); AppWin.Show(); an = new AubitNetwork(AubitNetwork.SocketStyle.SocketStyleEnvelope, client); AppWin.setConnection(an); an.startNetworkReceive(); } timer1.Enabled = true; }
private AubitNetwork createNetworkConnection(string server, string username, string password, string app, string port, AubitDesktop.Xml.Protocol protocol) { string cmd; string param; //frmMainAppWindow appWindow; if (app.Contains(" ")) { cmd = app.Substring(0, app.IndexOf(' ') - 1); param = app.Substring(app.IndexOf(' ') + 1); } else { cmd = app; param = ""; } param = param.Replace("<APPLICATION>", app); cmd = cmd.Replace("<APPLICATION>", app); param = param.Replace("<USER>", username); param = param.Replace("<PASSWORD>", password); param = param.Replace("<SERVER>", server); param = param.Replace("<IP>", LocalAddress); AubitNetwork networkConnection = new AubitNetwork(AubitNetwork.SocketStyle.SocketStyleLine); networkConnection.application = app; if (protocol.ListenMode && this.enableListeningModeToolStripMenuItem.Checked == false) { Program.Show("This protocol requires the client to be in 'Listening' mode - but that is currently disabled", "Can't start shortcut", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(null); } try { if (protocol.ListenMode == false) { // If we dont need listen mode - we need to open the connection already... this.AppWin = new frmMainAppWindow(); this.AppWin.Show(); this.AppWin.setConnection(networkConnection); } if (protocol.Command.ToLower() == "internal") { switch (protocol.Code) { case "SSH": // Calls back networkConnection.NewConnection(server, port, username, password, app, "SSH", this.AppWin); if (networkConnection.isConnected()) { // It managed it! networkConnection.Disconnect(); } else { Program.Show("Unable to start remote application"); } return(null); case "SSHT": networkConnection.NewConnection(server, port, username, password, app, "SSHT", this.AppWin); if (networkConnection.isConnected()) { AppWin.Show(); } break; case "RSH": // Calls back Program.Show("Not implemented yet..."); break; case "PROXY": networkConnection.NewConnection(server, port, username, password, app, "PROXY", AppWin); break; case "LOCAL": // Calls back System.Diagnostics.Process.Start(cmd, param); return(null); } } } catch (Exception ex) { Program.Show(ex.Message); } if (!networkConnection.isConnected()) { return(null); } else { return(networkConnection); } }