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 void btnConnect_Click(object sender, EventArgs e) { frmMainAppWindow appWindow; btnConnect.Enabled = false; appWindow = new frmMainAppWindow(this.txtServer.Text, 3490, txtApplication.Text, txtUsername.Text, txtPassword.Text, myConsole); /* * if (!appWindow.IsDisposed) * { * appWindow.Show(); * } * */ btnConnect.Enabled = true; }
public void NewConnection(string server, string port, string username, string password, string application, string ConnectionType, frmMainAppWindow appWindow) { connectionFailed = false; this.connectionType = ConnectionType; this.username = username; this.password = password; this.application = application; this.server = server; this._appwin = appWindow; switch (ConnectionType) { case "SSH": useExplicitStreams = true; NewConnectionSSH(server, port, username, password, application); break; case "SSHT": useExplicitStreams = true; NewConnectionSSH(server, port, username, password, application); break; case "PROXY": useExplicitStreams = false; NewConnectionTCP(server, port); if (tcpStream == null) { this.connectionFailed = true; this.OnConnectingFailed(new EventArgs()); return; } break; default: throw new ApplicationException("Invalid Connection type"); } }
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); } }
void n_ReceivedFromServer(object sender, ReceivedEventArgs e) { if (e.Data == "PROTOCOL?") { ((AubitNetwork)sender).SendString("UIVERSION 1.0"); return; } if (e.Data == "PROGRAMNAME?") { ((AubitNetwork)sender).SendString(this.application); return; } if (e.Data == "USER?") { ((AubitNetwork)sender).SendString(this.username); return; } if (e.Data == "PASSWORD?") { ((AubitNetwork)sender).SendString(this.password); return; } if (e.Data == "START") { ((AubitNetwork)sender).setEnvelopeMode(); Program.myConsole.ClearText(); appwin.Invoke(new MethodInvoker(appwin.ShowApplication)); //appwin.ShowApplication(); return; } if (e.Data == "FAILED TO START") { Program.Show("Application did not start\nIs that the correct Application name ? "); this.Disconnect(); this.connectionFailed = true; if (appwin.FailedToStart()) { appwin.Dispose(); appwin = null; } return; } if (e.Data == "AUTHFAILED") { Program.Show("Incorrect login details - connection refused"); this.Disconnect(); this.connectionFailed = true; if (appwin.FailedToStart()) { appwin.Dispose(); appwin = null; } //stdNetworkConnection = null; return; } if (e.Data == "TIMEOUT") { Program.Show("Timeout..."); if (appwin.FailedToStart()) { appwin.Dispose(); appwin = null; } return; } Program.Show(e.Data); }