Пример #1
0
        public void ReceiveShortMessage(String remoteUri, byte[] payload, String contentType)
        {
            if (ContentType.IS_COMPOSING.Equals(contentType, StringComparison.InvariantCultureIgnoreCase))
            {
                if (this.IsComposingAlertEnabled)
                {
                    this.imActivityIndicator.OnIndicationReceived(Encoding.UTF8.GetString(payload));
                }
                return;
            }
            System.Diagnostics.Debug.Assert(this.messagingType == MediaType.None ||
                                            this.MessagingType == MediaType.SMS || this.MessagingType == MediaType.ShortMessage);

            if (this.MessagingType == MediaType.None)
            {
                this.MessagingType = MediaType.SMS;
            }

            this.Show();

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(remoteUri);

            @event.Status  = HistoryEvent.StatusType.Incoming;
            @event.Content = Encoding.UTF8.GetString(payload);

            if (this.IsComposingAlertEnabled)
            {
                this.imActivityIndicator.OnContentReceived();
            }

            this.AddMessagingEvent(@event);
        }
Пример #2
0
        private void buttonSendText_Click(object sender, RoutedEventArgs e)
        {
            if (this.textBoxInput.Text == String.Empty)
            {
                return;
            }

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);

            @event.Status  = HistoryEvent.StatusType.Outgoing;
            @event.Content = this.textBoxInput.Text;

            switch (this.messagingType)
            {
            case MediaType.Chat:
            {
                if (this.ChatSession == null)
                {
                    this.ChatSession = this.CreateOutgoingSession(MediaType.Chat);
                }
                @event.SipSessionId = this.ChatSession.Id;
                this.ChatSession.SendMessage(this.textBoxInput.Text);
                this.textBoxInput.Text = String.Empty;
                break;
            }

            case MediaType.ShortMessage:
            case MediaType.SMS:
            default:
            {
                MyMessagingSession shortMessageSession = new MyMessagingSession(this.sipService.SipStack, this.remotePartyUri);
                if (this.UseBinarySMS)
                {
                    shortMessageSession.SendBinaryMessage(this.textBoxInput.Text, this.SMSCAddress);
                }
                else
                {
                    shortMessageSession.SendTextMessage(this.textBoxInput.Text);
                }
                this.textBoxInput.Text = String.Empty;
                shortMessageSession.Dispose();
                break;
            }
            }

            if (this.IsComposingAlertEnabled)
            {
                this.imActivityIndicator.OnContentSent();
            }

            this.AddMessagingEvent(@event);
        }
Пример #3
0
        private void buttonSendText_Click(object sender, RoutedEventArgs e)
        {
            if (this.ChatSession == null)
            {
                this.ChatSession = this.CreateOutgoingSession(MediaType.Chat);
            }
            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);

            @event.Status       = HistoryEvent.StatusType.Outgoing;
            @event.SipSessionId = this.ChatSession.Id;
            @event.Content      = this.textBoxInput.Text;
            this.AddMessagingEvent(@event);

            this.ChatSession.SendMessage(this.textBoxInput.Text);
            this.textBoxInput.Text = String.Empty;
        }
        private void ItemHistoryChatEvent_ValueLoaded(object sender, EventArgs e)
        {
            HistoryChatEvent @event = this.Value;

            this.labelDisplayName.Content = @event.DisplayName;
            this.labelDate.Content        = BaseItem <HistoryChatEvent> .GetFriendlyDateString(@event.Date);

            this.textBockMessage.Text = String.Empty;
            if (@event.Messages.Count > 0)
            {
                HistoryShortMessageEvent shortMessage = @event.Messages[0];
                this.textBockMessage.Text = shortMessage.Content ?? shortMessage.Content;
            }

            this.Width = Double.NaN;
        }
Пример #5
0
        public void ReceiveShortMessage(String remoteUri, byte[] payload, String contentType)
        {
            System.Diagnostics.Debug.Assert(this.messagingType == MediaType.None ||
                                            this.MessagingType == MediaType.SMS || this.MessagingType == MediaType.ShortMessage);

            if (this.MessagingType == MediaType.None)
            {
                this.MessagingType = MediaType.SMS;
            }

            this.Show();

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(remoteUri);

            @event.Status  = HistoryEvent.StatusType.Incoming;
            @event.Content = Encoding.UTF8.GetString(payload);
            this.AddMessagingEvent(@event);
        }
Пример #6
0
        private void ChatSession_onMsrpEvent(object sender, MsrpEventArgs e)
        {
            if (this.ChatSession == null || this.ChatSession.Id != e.SessionId)
            {
                LOG.Error("Invalid chat session");
                return;
            }

            if (this.Dispatcher.Thread != Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                        new EventHandler<MsrpEventArgs>(this.ChatSession_onMsrpEvent), sender, new object[] { e });
                return;
            }

            switch (e.Type)
            {
                case MsrpEventTypes.CONNECTED:
                    break;

                case MsrpEventTypes.DISCONNECTED:
                    {
                        this.ChatSession = null;
                        break;
                    }

                case MsrpEventTypes.DATA:
                    {
                        byte[] data = (e.GetExtra(MsrpEventArgs.EXTRA_DATA) as byte[]);
                        if (data != null)
                        {
                            String contentType = (e.GetExtra(MsrpEventArgs.EXTRA_CONTENT_TYPE) as String);

                            if (contentType != null)
                            {
                                contentType = contentType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0];
                                if (contentType.Equals(ContentType.CPIM, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Object wrappedContentType = e.GetExtra(MsrpEventArgs.EXTRA_WRAPPED_CONTENT_TYPE);
                                    contentType = wrappedContentType == null ? "UnknowWrappedType" : wrappedContentType as String;
                                }
                            }

                            if (ContentType.IS_COMPOSING.Equals(contentType, StringComparison.InvariantCultureIgnoreCase))
                            {
                                this.imActivityIndicator.OnIndicationReceived(Encoding.UTF8.GetString(data));
                                return;
                            }

                            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);
                            @event.Status = HistoryEvent.StatusType.Incoming;
                            if (contentType.Equals(ContentType.TEXT_PLAIN, StringComparison.InvariantCultureIgnoreCase))
                            {
                                @event.Content = Encoding.UTF8.GetString(data);
                            }
                            else
                            {
                                @event.Content = String.Format("{0} not supported as content type", contentType);
                                LOG.Warn(@event.Content);
                            }

                            if (this.IsComposingAlertEnabled)
                            {
                                this.imActivityIndicator.OnContentReceived();
                            }

                            this.AddMessagingEvent(@event);
                        }
                        break;
                    }

                case MsrpEventTypes.ERROR:
                    break;

                case MsrpEventTypes.SUCCESS_2XX:
                    break;

                case MsrpEventTypes.SUCCESS_REPORT:
                    break;
            }
        }
Пример #7
0
        private void ChatSession_onMsrpEvent(object sender, MsrpEventArgs e)
        {
            if (this.ChatSession == null || this.ChatSession.Id != e.SessionId)
            {
                LOG.Error("Invalid chat session");
                return;
            }

            if (this.Dispatcher.Thread != Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                            new EventHandler <MsrpEventArgs>(this.ChatSession_onMsrpEvent), sender, new object[] { e });
                return;
            }

            switch (e.Type)
            {
            case MsrpEventTypes.CONNECTED:
                break;

            case MsrpEventTypes.DISCONNECTED:
            {
                this.ChatSession = null;
                break;
            }

            case MsrpEventTypes.DATA:
            {
                byte[] data = (e.GetExtra(MsrpEventArgs.EXTRA_DATA) as byte[]);
                if (data != null)
                {
                    String contentType = (e.GetExtra(MsrpEventArgs.EXTRA_CONTENT_TYPE) as String);

                    if (contentType != null)
                    {
                        contentType = contentType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0];
                        if (contentType.Equals(ContentType.CPIM, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Object wrappedContentType = e.GetExtra(MsrpEventArgs.EXTRA_WRAPPED_CONTENT_TYPE);
                            contentType = wrappedContentType == null ? "UnknowWrappedType" : wrappedContentType as String;
                        }
                    }

                    if (ContentType.IS_COMPOSING.Equals(contentType, StringComparison.InvariantCultureIgnoreCase))
                    {
                        LOG.Warn("Ignore is-composing content");
                        return;
                    }

                    HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);
                    @event.Status = HistoryEvent.StatusType.Incoming;
                    if (contentType.Equals(ContentType.TEXT_PLAIN, StringComparison.InvariantCultureIgnoreCase))
                    {
                        @event.Content = Encoding.UTF8.GetString(data);
                    }
                    else
                    {
                        @event.Content = String.Format("{0} not supported as content type", contentType);
                        LOG.Warn(@event.Content);
                    }
                    this.AddMessagingEvent(@event);
                }
                break;
            }

            case MsrpEventTypes.ERROR:
                break;

            case MsrpEventTypes.SUCCESS_2XX:
                break;

            case MsrpEventTypes.SUCCESS_REPORT:
                break;
            }
        }
Пример #8
0
        private void buttonSendText_Click(object sender, RoutedEventArgs e)
        {
            if (this.textBoxInput.Text == String.Empty)
            {
                return;
            }

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);
            @event.Status = HistoryEvent.StatusType.Outgoing;
            @event.Content = this.textBoxInput.Text;

            switch (this.messagingType)
            {
                case MediaType.Chat:
                    {
                        if (this.ChatSession == null)
                        {
                            this.ChatSession = this.CreateOutgoingSession(MediaType.Chat);
                        }
                        @event.SipSessionId = this.ChatSession.Id;
                        this.ChatSession.SendMessage(this.textBoxInput.Text);
                        this.textBoxInput.Text = String.Empty;
                        break;
                    }

                case MediaType.ShortMessage:
                case MediaType.SMS:
                default:
                    {
                        MyMessagingSession shortMessageSession = new MyMessagingSession(this.sipService.SipStack, this.remotePartyUri);
                        if (this.UseBinarySMS)
                        {
                            shortMessageSession.SendBinaryMessage(this.textBoxInput.Text, this.SMSCAddress);
                        }
                        else
                        {
                            shortMessageSession.SendTextMessage(this.textBoxInput.Text);
                        }
                        this.textBoxInput.Text = String.Empty;
                        shortMessageSession.Dispose();
                        break;
                    }
            }

            this.AddMessagingEvent(@event);
        }
Пример #9
0
        public void ReceiveShortMessage(String remoteUri, byte[] payload, String contentType)
        {
            System.Diagnostics.Debug.Assert(this.messagingType == MediaType.None
            || this.MessagingType == MediaType.SMS || this.MessagingType == MediaType.ShortMessage);

            if (this.MessagingType == MediaType.None)
            {
                this.MessagingType = MediaType.SMS;
            }

            this.Show();

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(remoteUri);
            @event.Status = HistoryEvent.StatusType.Incoming;
            @event.Content = Encoding.UTF8.GetString(payload);
            this.AddMessagingEvent(@event);
        }
Пример #10
0
        private void buttonSendText_Click(object sender, RoutedEventArgs e)
        {
            if (this.ChatSession == null)
            {
                this.ChatSession = this.CreateOutgoingSession(MediaType.Chat);
            }
            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(this.remotePartyUri);
            @event.Status = HistoryEvent.StatusType.Outgoing;
            @event.SipSessionId = this.ChatSession.Id;
            @event.Content = this.textBoxInput.Text;
            this.AddMessagingEvent(@event);

            this.ChatSession.SendMessage(this.textBoxInput.Text);
            this.textBoxInput.Text = String.Empty;

            if (this.IsComposingAlertEnabled)
            {
                this.imActivityIndicator.OnContentSent();
            }
        }
Пример #11
0
        public void ReceiveShortMessage(String remoteUri, byte[] payload, String contentType)
        {
            if (ContentType.IS_COMPOSING.Equals(contentType, StringComparison.InvariantCultureIgnoreCase))
            {
                if (this.IsComposingAlertEnabled)
                {
                    this.imActivityIndicator.OnIndicationReceived(Encoding.UTF8.GetString(payload));
                }
                return;
            }
            System.Diagnostics.Debug.Assert(this.messagingType == MediaType.None
            || this.MessagingType == MediaType.SMS || this.MessagingType == MediaType.ShortMessage);

            if (this.MessagingType == MediaType.None)
            {
                this.MessagingType = MediaType.SMS;
            }

            this.Show();

            HistoryShortMessageEvent @event = new HistoryShortMessageEvent(remoteUri);
            @event.Status = HistoryEvent.StatusType.Incoming;
            @event.Content = Encoding.UTF8.GetString(payload);

            if (this.IsComposingAlertEnabled)
            {
                this.imActivityIndicator.OnContentReceived();
            }

            this.AddMessagingEvent(@event);
        }