Пример #1
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        /// <summary>
        /// Tries to parse the given string to a MUCRole.
        /// Returns MUCRole.VISITOR as a default value if it fails.
        /// </summary>
        /// <param name="role">The string that should get parsed to a MUCRole.</param>
        /// <returns>Returns the MUCRole based on the given string. Defaults to: MUCRole.VISITOR</returns>
        public static MUCRole parseMUCRole(string role)
        {
            MUCRole r = MUCRole.VISITOR;

            Enum.TryParse(role.ToUpper(), out r);
            return(r);
        }
Пример #2
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        /// <summary>
        /// Basic Constructor
        /// </summary>
        /// <history>
        /// 07/01/2018 Created [Fabian Sauter]
        /// </history>
        public MUCMemberPresenceMessage(XmlNode node) : base(node)
        {
            this.FROM_NICKNAME = Utils.getJidResourcePart(FROM);
            this.STATUS_CODES  = new List <MUCPresenceStatusCode>();
            XmlNode xNode = XMLUtils.getChildNode(node, "x", Consts.XML_XMLNS, "http://jabber.org/protocol/muc#user");

            if (xNode != null)
            {
                foreach (XmlNode n in xNode.ChildNodes)
                {
                    switch (n.Name)
                    {
                    case "item":
                        this.AFFILIATION = Utils.parseMUCAffiliation(n.Attributes["affiliation"]?.Value);
                        this.ROLE        = Utils.parseMUCRole(n.Attributes["role"]?.Value);
                        this.JID         = n.Attributes["jid"]?.Value;
                        this.NICKNAME    = n.Attributes["nick"]?.Value;
                        break;

                    case "status":
                        string s = n.Attributes["code"]?.Value;
                        if (s != null)
                        {
                            this.STATUS_CODES.Add(parseStatusCode(s));
                        }
                        break;
                    }
                }
            }

            XmlNode eNode = XMLUtils.getChildNode(node, "error");

            if (eNode != null)
            {
                this.ERROR_TYPE    = eNode.Attributes["type"]?.Value;
                this.ERROR_MESSAGE = eNode.InnerText;
            }
        }
Пример #3
0
 /// <summary>
 /// Converts the given MUCRole to the equivalent string representation.
 /// e.g. MUCRole.VISITOR => 'visitor'
 /// </summary>
 public static string mucRoleToString(MUCRole role)
 {
     return(role.ToString().ToLower());
 }