mftaha / jabber-net

Automatically exported from code.google.com/p/jabber-net
Other
0 stars 0 forks source link

NullReference Exception getting Subject from Room on Join #100

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Initialize Client and connect to a chat server.
2. Initialize ConferenceManager for this client
3. Subscribe to the OnParticipantJoin event for conference manager. When this 
event 
fires, try to grab the Subject of the room argument.
4. Join an existing room with at least one participant.
5. NullReference Exception occurs when trying to grab the Subject.

What is the expected output? What do you see instead?
Expected: null for subject
Got: Null Reference Exception trying to retrieve the property.

What version of the product are you using? On what operating system?
Jabber-Net Library 2.1.0.702
Windows XP

Please provide any additional information below.
Working with .NET 3.5
Investigated with MS Visual Studio,
Discovered that in ConferenceManager.cs, line 530, the getter for the Subject 
property 
is returning m_subject.Subject. At the time of Participant Join firing, 
m_subject is 
null. My suggested patch:

        /// <summary>
        /// The subject of the room.  Set has the side-effect of sending to the server.
        /// </summary>
        public string Subject
        {
            get 
            {
                if (m_subject != null)
                    return m_subject.Subject;
                else return null;
            }
            set
            {
                Message m = new Message(m_stream.Document);
                m.To = m_room;
                m.Type = MessageType.groupchat;
                m.Subject = value;
                m.Body = "/me has changed the subject to: " + value;
                m_stream.Write(m);
            }
        }

Original issue reported on code.google.com by theycall...@gmail.com on 30 Mar 2010 at 9:42