예제 #1
0
        public void OnConnect(object sender, EventArgs e)
        {
            // We need an XID and Password to connect to the server.
            if (String.IsNullOrEmpty(Settings.Password))
            {
                Events.Error(this, ErrorType.MissingPassword, ErrorPolicyType.Deactivate);
            }
            else if (String.IsNullOrEmpty(Settings.Id))
            {
                Events.Error(this, ErrorType.MissingJID, ErrorPolicyType.Deactivate);
            }
            else if (String.IsNullOrEmpty(Settings.Hostname))
            {
                Events.Error(this, ErrorType.MissingHost, ErrorPolicyType.Deactivate);
            }
            else
            {
#if DEBUG
                Events.LogMessage(this, LogType.Info, "Connecting to {0}", Connection.Hostname);
#endif

                // Set the current state to connecting and start the process.
                State = new ConnectingState(this);
                State.Execute();
            }
        }
예제 #2
0
        /// <inheritdoc />
        public void Connect(Jid jid, string password)
        {
            if (jid is null)
            {
                throw new ArgumentNullException(nameof(jid));
            }

            _logger.Log(LogLevel.Debug, $"Connecting to server for {jid}");
            Id = jid;
            Password = password;
            State = new ConnectingState();
            State.Execute(this);
        }