예제 #1
0
        /// <summary>
        /// Connects to the server for the profile that is currently loaded.
        /// </summary>
        public void Connect()
        {
            // Activate any plugins for this game.
            ActivatePlugins();

            // Connect, then put the focus into the input text box.
            Interp.Connect(HandleLineReceived, this.HandleDataReceived, HandleConnectionClosed);
            TabMain.IsConnected = true;
            TextInput.Focus();

            // If a command has been defined to send after connect then check it and fire it off here.
            if (!string.IsNullOrWhiteSpace(App.Settings.ProfileSettings.OnConnect))
            {
                var source = new CancellationTokenSource();

                var t = Task.Run(async delegate
                {
                    await Task.Delay(TimeSpan.FromMilliseconds(App.Settings.ProfileSettings.OnConnectDelayMilliseconds), source.Token);

                    Application.Current.Dispatcher.Invoke(new Action(async() =>
                    {
                        await Interp.Send(App.Settings.ProfileSettings.OnConnect);
                    }));

                    return;
                });
            }
        }
예제 #2
0
        /// <summary>
        /// Connects to the server for the profile that is currently loaded.
        /// </summary>
        public void Connect()
        {
            // Load any plugins into the System Triggers.
            LoadPlugins();

            // Connect, then put the focus into the input text box.
            Interp.Connect(HandleLineReceived, this.HandleDataReceived, HandleConnectionClosed);
            TabMain.IsConnected = true;
            TextInput.Focus();
        }
예제 #3
0
        /// <summary>
        /// Connects to the server for the profile that is currently loaded.
        /// </summary>
        public async Task Connect()
        {
            try
            {
                // Activate any plugins for this game.
                ActivatePlugins();

                // Connect, then put the focus into the input text box.
                await Interp.Connect(HandleLineReceived, this.HandleDataReceived, HandleConnectionClosed);

                TitleBar.IsConnected     = true;
                MenuNetworkButton.Header = "Disconnect";
                TextInput.Focus();

                // If a command has been defined to send after connect then check it and fire it off here.
                if (!string.IsNullOrWhiteSpace(App.Settings.ProfileSettings.OnConnect))
                {
                    var source = new CancellationTokenSource();

                    var t = Task.Run(async delegate
                    {
                        await Task.Delay(TimeSpan.FromMilliseconds(App.Settings.ProfileSettings.OnConnectDelayMilliseconds), source.Token);

                        Application.Current.Dispatcher.Invoke(new Action(async() =>
                        {
                            if (Interp.Telnet != null && Interp.Telnet.IsConnected())
                            {
                                await Interp.Send(App.Settings.ProfileSettings.OnConnect);
                            }
                        }));
                    });
                }
            }
            catch (Exception ex)
            {
                App.Conveyor.EchoError($"Network Failure: {ex.Message}");
            }
        }