示例#1
0
        public override Tag Initialize(XID id, string password)
        {
            base.Initialize(id, password);

            Auth tag = (Auth)TagRegistry.Instance.GetTag("auth", Namespaces.SASL, new XmlDocument());
            tag.Mechanism = Mechanism.GetMechanism(MechanismType.DIGEST_MD5);
            return tag;
        }
示例#2
0
        public void NewXIDFromString()
        {
            XID id = new XID("[email protected]/home");

            Assert.That(id.User, Is.EqualTo("testing"));
            Assert.That(id.Server, Is.EqualTo("jabber.org"));
            Assert.That(id.Resource, Is.EqualTo("home"));
        }
示例#3
0
 private void button1_Click(object sender, EventArgs e)
 {
     XID id = new XID(txtUsername.Text);
     xmpp = XMPP.Connect(id, txtPassword.Text, ssl: btnSSL.Checked);
 }
示例#4
0
        /// <summary>
        /// Connect to an XMPP server.
        /// </summary>
        /// <param name="id">The XID to be used for connecting.</param>
        /// <param name="password">The password to be used for authentication</param>
        /// <param name="hostname">The hostname to connect to. Can be set to null to use XID server.</param>
        /// <param name="port">The port to connect to if one is not provided by an SRV record.</param>
        /// <param name="ssl">Use encryption if available?</param>
        /// <returns></returns>
        public static XMPP Connect(XID id, string password, string hostname = null, int port = 5222, bool ssl = false)
        {
            XMPP me = new XMPP();

            _states.Socket = new AsyncSocket();
            // We need an XID and Password to connect to the server.
            if (String.IsNullOrEmpty(password))
            {
                _errors.SendError(typeof(XMPP), ErrorType.MissingPassword, "Set the Password property before connecting.", true);
                return null;
            }
            else if (String.IsNullOrEmpty(id))
            {
                _errors.SendError(typeof(XMPP), ErrorType.MissingID, "Set the ID property before connecting.", true);
                return null;
            }

            // Do we use the server supplied from the XID or the alternate provided by the developer?
            if (!String.IsNullOrEmpty(hostname))
                _states.Socket.Hostname = hostname;
            else
                _states.Socket.Hostname = id.Server;

            Logger.InfoFormat(typeof(XMPP), "Connecting to {0}", _states.Socket.Hostname);

            _states.ID = id;
            _states.Password = password;

            // Set the values we need to connect.
            _states.Socket.SSL = ssl;
            _states.Socket.Port = port;
            // Set the current state to connecting and start the process.
            _states.State = new ConnectingState();
            _states.Execute();

            return me;
        }
示例#5
0
 public static XMPP Connect(XID id, string password)
 {
     return Connect(id, password, id.Server, 5222, false);
 }
示例#6
0
        public void EscapeUsernameFromString()
        {
            XID id = new XID("d'[email protected]/testing");

            Assert.That(id.ToString(), Is.EqualTo(@"d\[email protected]/testing"));
        }