Exemple #1
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);
        }
        private void imActivityIndicator_SendMessageEvent(object sender, EventArgs e)
        {
            if (this.IsComposingAlertEnabled && this.participants.Count > 0)
            {
                if (this.Dispatcher.Thread != Thread.CurrentThread)
                {
                    this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                            new EventHandler<EventArgs>(this.imActivityIndicator_SendMessageEvent), sender, new object[] { e });
                    return;
                }

                switch (this.messagingType)
                {
                    case MediaType.Chat:
                        {
                            if (this.ChatSession != null)
                            {
                                this.ChatSession.SendMessage(this.imActivityIndicator.GetMessageIndicator(), ContentType.IS_COMPOSING, null);
                            }
                            break;
                        }

                    case MediaType.ShortMessage:
                    case MediaType.SMS:
                    default:
                        {
                            if (!this.UseBinarySMS)
                            {
                                MyMessagingSession shortMessageSession = new MyMessagingSession(this.sipService.SipStack, this.remotePartyUri);
                                shortMessageSession.SendTextMessage(this.imActivityIndicator.GetMessageIndicator(), ContentType.IS_COMPOSING);
                                shortMessageSession.Dispose();
                            }
                            break;
                        }
                }
            }
        }