Exemplo n.º 1
0
 public void AddMessage( AbstractMessagePacket msg )
 {
     if (msg is MessageErrorPacket)
     {
         MessageErrorPacket er = WConvert.ToMessageErrorPacket(msg);
         HandleMessageError(er);
     }
     else if (msg is GroupChatMessage)
     {
         GroupChatMessage gc = WConvert.ToGroupChatMessage(msg);
         AddMessageHistory(msg.From, gc.Body);
     }
     else if (msg is ChangeSubjectMessage)
     {
         ChangeSubjectMessage cs = WConvert.ToChangeSubjectMessage(msg);
         AddSubjectChange(cs);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Event received from the SessionManager when a message packet is received.
 /// This is either a MessagePacket or a MessageErrorPacket.
 /// The packet is processed and a new message window is created if applicable.
 /// If a message window already exists it will have received the event as well
 /// and we can ignore the packet.
 /// </summary>
 /// <param name="IncomingMessagePacket">The Message packet that was just received.</param>
 private void OnIncomingMessage(AbstractMessagePacket IncomingMessagePacket)
 {
     //Determine the type of packet.
     //If MessageErrorPacket
     //	 Show the MessageErrorPacket in a MessageBox.
     //If MessagePacket
     //   Grab the message window for this user.
     //Determine the type of packet.
     if (IncomingMessagePacket is MessageErrorPacket)
     {
         MessageErrorPacket msgError = (MessageErrorPacket)IncomingMessagePacket;
         MessageBox.Show(string.Format("The following message error packet was received:\n\nCode: {0}\nText: {1}.", msgError.ErrorCode, msgError.ErrorText), "Message Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
     }
     else if (IncomingMessagePacket is MessagePacket)
     {
         MessagePacket msgPacket = (MessagePacket)IncomingMessagePacket;
         this.Invoke(new Session.PacketReceivedDelegate(IncomingAsyncMessage), new object[] { msgPacket });
     }
     else
     {
         // It's some other type, just ignore it.
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Event received from SessionManager when a message packet is received.
        /// </summary>        
        private void OnIncomingMessage(AbstractMessagePacket IncomingMessagePacket)
        {
            if (IncomingMessagePacket is MessageErrorPacket)
            {
                MessageErrorPacket msgError = (MessageErrorPacket)IncomingMessagePacket;
                if (msgError.To.ToString().ToLower().Equals(LocalUser.ToString().ToLower()))
                    MessageBox.Show(
                        string.Format("The following message error packet was received:\n\nCode: {0}\nText: {1}", msgError.ErrorCode, msgError.ErrorText));
            }
            else if (IncomingMessagePacket is MessagePacket)
            {
                MessagePacket msgPacket = (MessagePacket)IncomingMessagePacket;

                if (msgPacket.From.Equals(RemoteUser, JabberID.JabberIDCompareEnum.JabberIDCompareWithResource) ||
                    msgPacket.Thread.Equals(MessageThreadID, StringComparison.InvariantCultureIgnoreCase))
                {
                    this.Invoke(new Session.PacketReceivedDelegate(IncomingAsyncMessage), new object[]{msgPacket});
                }
            }
        }