Beispiel #1
0
        /// <summary>
        ///   Sends a chat state notification
        /// </summary>
        /// <param name = "notificationType"></param>
        public void SendChatStateNotification(XmppChatStateNotification notificationType)
        {
            // Generate the notification only if the target entity supports it
            if (Contact.SupportsChatStateNotifications)
            {
                var message = new Message
                {
                    ID   = XmppIdentifierGenerator.Generate(),
                    Type = MessageType.Chat,
                    From = session.UserId.ToString(),
                    To   = Contact.ContactId.ToString(),
                };

                message.Items.Add(CreateChatStateNotification(notificationType));

                session.Send(message);
            }
        }
Beispiel #2
0
        private void Initialize(Message message)
        {
            identifier            = message.ID;
            @from                 = message.From;
            to                    = message.To;
            language              = message.Lang;
            type                  = message.Type;
            thread                = String.Empty;
            chatStateNotification = XmppChatStateNotification.None;

            foreach (object item in message.Items)
            {
                if (item is MessageBody)
                {
                    body = ((MessageBody)item).Value;
                }
                else if (item is MessageSubject)
                {
                    subject = ((MessageSubject)item).Value;
                }
                else if (item is NotificationActive)
                {
                    chatStateNotification = XmppChatStateNotification.Active;
                }
                else if (item is NotificationComposing)
                {
                    chatStateNotification = XmppChatStateNotification.Composing;
                }
                else if (item is NotificationGone)
                {
                    chatStateNotification = XmppChatStateNotification.Gone;
                }
                else if (item is NotificationInactive)
                {
                    chatStateNotification = XmppChatStateNotification.Inactive;
                }
                else if (item is NotificationPaused)
                {
                    chatStateNotification = XmppChatStateNotification.Paused;
                }
            }
        }
Beispiel #3
0
        private static object CreateChatStateNotification(XmppChatStateNotification notificationType)
        {
            switch (notificationType)
            {
            case XmppChatStateNotification.Active:
                return(new NotificationComposing());

            case XmppChatStateNotification.Composing:
                return(new NotificationComposing());

            case XmppChatStateNotification.Gone:
                return(new NotificationGone());

            case XmppChatStateNotification.Inactive:
                return(new NotificationInactive());

            case XmppChatStateNotification.Paused:
                return(new NotificationPaused());
            }

            return(null);
        }
Beispiel #4
0
 /// <summary>
 /// Sends a chat state notification
 /// </summary>
 /// <param name="notificationType">Chat state notification type</param>
 public void SendChatStateNotification(XmppChatStateNotification notificationType)
 {
     Task.Factory.StartNew
     (
         () =>
         {
             this.chat.SendChatStateNotification(notificationType);
         }
     );
 }
Beispiel #5
0
        private void Initialize(Message message)
        {
            this.identifier             = message.ID;
            this.from                   = message.From;
            this.to			            = message.To;
            this.language               = message.Lang;
            this.type                   = message.Type;
            this.thread                 = String.Empty;
            this.chatStateNotification  = XmppChatStateNotification.None;

            foreach (object item in message.Items)
            {
                if (item is MessageBody)
                {
                    this.body = ((MessageBody)item).Value;
                }
                else if (item is MessageSubject)
                {
                    this.subject = ((MessageSubject)item).Value;
                }
                else if (item is NotificationActive)
                {
                    this.chatStateNotification = XmppChatStateNotification.Active;
                }
                else if (item is NotificationComposing)
                {
                    this.chatStateNotification = XmppChatStateNotification.Composing;
                }
                else if (item is NotificationGone)
                {
                    this.chatStateNotification = XmppChatStateNotification.Gone;
                }
                else if (item is NotificationInactive)
                {
                    this.chatStateNotification = XmppChatStateNotification.Inactive;
                }
                else if (item is NotificationPaused)
                {
                    this.chatStateNotification = XmppChatStateNotification.Paused;
                }
            }
        }
Beispiel #6
0
        private static object CreateChatStateNotification(XmppChatStateNotification notificationType)
        {
            switch (notificationType)
            {
                case XmppChatStateNotification.Active:
                    return new NotificationComposing();

                case XmppChatStateNotification.Composing:
                    return new NotificationComposing();

                case XmppChatStateNotification.Gone:
                    return new NotificationGone();

                case XmppChatStateNotification.Inactive:
                    return new NotificationInactive();

                case XmppChatStateNotification.Paused:
                    return new NotificationPaused();
            }

            return null;
        }
Beispiel #7
0
        /// <summary>
        ///   Sends a chat state notification
        /// </summary>
        /// <param name = "notificationType"></param>
        public void SendChatStateNotification(XmppChatStateNotification notificationType)
        {
            // Generate the notification only if the target entity supports it
            if (Contact.SupportsChatStateNotifications)
            {
                var message = new Message
                                  {
                                      ID = XmppIdentifierGenerator.Generate(),
                                      Type = MessageType.Chat,
                                      From = session.UserId.ToString(),
                                      To = Contact.ContactId.ToString(),
                                  };

                message.Items.Add(CreateChatStateNotification(notificationType));

                session.Send(message);
            }
        }