コード例 #1
0
ファイル: Session.cs プロジェクト: madboy06/sip-softphone
        /// <summary>
        /// Create and start AV session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartAVSession(string avRemoteUri)
        {
            this.avRemoteUri = avRemoteUri;

            // Create AV session
            CreateSession(UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO);

            // Create remote participant
            UccUriManager                    uriManager    = new UccUriManager();
            IUccSessionParticipant           participant   = this.avSession.CreateParticipant(uriManager.ParseUri(this.avRemoteUri), null);
            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            // Create audio channel
            IUccMediaChannel channel = avParticipant.CreateChannel(UCC_MEDIA_TYPES.UCCMT_AUDIO, null);

            channel.PreferredMedia = (int)(UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE | UCC_MEDIA_DIRECTIONS.UCCMD_SEND);

            // Add channel
            avParticipant.AddChannel(channel);

            UccOperationContext context = new UccOperationContextClass();

            context.Initialize(operationId++, null);
            // Add remote participant
            this.avSession.AddParticipant(participant, context);
        }
コード例 #2
0
ファイル: Endpoint.cs プロジェクト: KhaledSMQ/SipServer
        private void Publish()
        {
            UccOperationContext operationContext = new UccOperationContextClass();

            operationContext.Initialize(0, new UccContextClass());

            IUccPublicationManager publicationManager = (IUccPublicationManager)this.endpoint;

            IUccCategoryInstance categoryInstance = null;

            //this.selfPresentity.CreatePublishableStateCategoryInstance();

            if (categoryInstance == null)
            {
                categoryInstance = publicationManager.CreatePublishableCategoryInstance(
                    CategoryName.State, 2, 0, UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_DEVICE, 0);

                operationContext.Context.AddProperty(ContextInitialPublication, true);
            }

            categoryInstance.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD;

            IUccPresenceStateInstance stateInstance = (IUccPresenceStateInstance)categoryInstance;

            stateInstance.Availability = (int)this.SelfPresentity.Availability;
            stateInstance.Type         = UCC_PRESENCE_STATE_TYPE.UCCPST_USER_STATE;

            IUccPublication publication = publicationManager.CreatePublication();

            ComEvents.Advise <_IUccPublicationEvent>(publication, this);
            publication.AddPublishableCategoryInstance(categoryInstance);

            publication.Publish(operationContext);
        }
コード例 #3
0
ファイル: Endpoint.cs プロジェクト: KhaledSMQ/SipServer
        public int BeginUserSearch(string searchDomain, IEnumerable <string> searchTerms)
        {
            IUccUserSearchQuery query = this.userSearchManager.CreateQuery();

            ComEvents.Advise <_IUccUserSearchQueryEvents>(query, this);

            query.SearchDomain = searchDomain;

            string name = null;

            foreach (string item in searchTerms)
            {
                if (string.IsNullOrEmpty(name))
                {
                    name = item;
                }
                else
                {
                    query.set_SearchTerm(name, item);
                    name = null;
                }
            }

            UccOperationContext operationContext = new UccOperationContextClass();

            operationContext.Initialize(0, new UccContextClass());

            query.Execute(operationContext);

            return(operationContext.OperationId);
        }
コード例 #4
0
ファイル: ImSession.cs プロジェクト: madboy06/sip-softphone
        public IOutgoingMessage Send(string contentType, string content)
        {
            OutgoingMessage message = this.CreateOutgoingMessage(contentType, content);

            var error = ValidateSession();

            if (error == null)
            {
                message.State = OutgoingMessageState.Sending;
                this.sendingMessages.Add(message.Id, message);

                UccOperationContext operationContext = new UccOperationContextClass();
                operationContext.Initialize(0, new UccContextClass());
                operationContext.Context.AddProperty(ContextMessageId, message.Id);

                this.uccImSession.SendMessage(message.ContentType, message.Message, operationContext);
            }
            else
            {
                message.Error = error;
                message.State = OutgoingMessageState.Failed;
                if (SendResult != null)
                {
                    SendResult(this, new ImSessionEventArgs1(message));
                }
            }

            return(message);
        }
コード例 #5
0
ファイル: Session.cs プロジェクト: madboy06/sip-softphone
 /// <summary>
 /// End the AV session
 /// </summary>
 public void EndAVSession()
 {
     if (this.avSession != null)
     {
         UccOperationContext context = new UccOperationContextClass();
         context.Initialize(operationId++, null);
         this.avSession.Terminate(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_NOT_SPECIFIED, context);
     }
 }
コード例 #6
0
 /// <summary>
 /// Shutdown the platform
 /// </summary>
 public void ShutdownPlatform()
 {
     if (this.platform != null)
     {
         // Shutdown platform
         UccOperationContext context = new UccOperationContextClass();
         context.Initialize(operationId++, null);
         this.platform.Shutdown(context);
     }
 }
コード例 #7
0
        /// <summary>
        /// Send an instance message to remote participant.
        /// </summary>
        /// <param name="message"></param>
        public void SessionSendMessage(string message)
        {
            IUccInstantMessagingSession session = this.imSession as IUccInstantMessagingSession;
            if (session == null)
                return;
            UccOperationContext context = new UccOperationContextClass();
            context.Initialize(operationId++, null);
            session.SendMessage(contentType, message, context);

            string formatMessage = string.Format("{0}: \r\n {1}", uri, message);
            this.mainForm.WriteIMMessage(formatMessage);
        }
コード例 #8
0
ファイル: IMSession.cs プロジェクト: madboy06/sip-softphone
        /// <summary>
        /// Send an instance message to remote participant.
        /// </summary>
        /// <param name="message"></param>
        public void SessionSendMessage(string message)
        {
            IUccInstantMessagingSession session = this.imSession as IUccInstantMessagingSession;

            UccOperationContext context = new UccOperationContextClass();

            context.Initialize(operationId++, null);
            session.SendMessage(contentType, message, context);

            string formatMessage = string.Format("{0}: \r\n {1}", uri, message);

            this.mainForm.WriteIMMessage(formatMessage);
        }
コード例 #9
0
ファイル: Session.cs プロジェクト: madboy06/sip-softphone
        public ParticipantLog AddPartipant(string uri)
        {
            uri = Helpers.CorrectUri(uri);
            var log = this.GetPartipantLog(uri);

            if (this.UccSession == null)
            {
                log.State = PartipantLogState.SessionTerminated;
            }
            else
            {
                //if (Helpers.IsUriEqual(uri, this.PartipantLogs[0].Uri))
                //{
                //    log.SetState(PartipantLogState.InvalidUri, @"URI is invalid, loopback is not allowed");
                //    return log;
                //}

                foreach (IUccSessionParticipant participant in this.UccSession.Participants)
                {
                    if (Helpers.IsUriEqual(uri, participant.Uri))
                    {
                        return(log);
                    }
                }

                UccUri uccUri;
                if (Helpers.TryParseUri(uri, out uccUri))
                {
                    log.State = PartipantLogState.AddBegin;

                    IUccSessionParticipant participant = this.UccSession.CreateParticipant(uccUri, null);

                    this.AddChannel(participant);

                    UccOperationContext operationContext = new UccOperationContextClass();
                    operationContext.Initialize(0, new UccContextClass());
                    operationContext.Context.AddProperty(ContextParticipantUri, uri);

                    this.UccSession.AddParticipant(participant, operationContext);
                }
                else
                {
                    log.SetState(PartipantLogState.InvalidUri, @"URI is invalid, e.g. sip:[email protected]");
                }
            }

            return(log);
        }
コード例 #10
0
ファイル: Session.cs プロジェクト: madboy06/sip-softphone
        /// <summary>
        /// Create and start IM session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartIMSession(string imRemoteUri)
        {
            this.imRemoteUri = imRemoteUri;

            // Create IM session
            CreateSession(UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING);

            // Create remote participant
            UccUriManager          uriManager  = new UccUriManager();
            IUccSessionParticipant participant = this.imSession.CreateParticipant(uriManager.ParseUri(this.imRemoteUri), null);

            UccOperationContext context = new UccOperationContextClass();

            context.Initialize(operationId++, null);
            // Add remote participant
            this.imSession.AddParticipant(participant, context);
        }
コード例 #11
0
 /// <summary>
 /// End the AV session
 /// </summary>
 public void EndAVSession()
 {
     if (this.avSession != null)
     {
         UccOperationContext context = new UccOperationContextClass();
         context.Initialize(operationId++, null);
         this.avSession.Terminate(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_NOT_SPECIFIED, context);
     }
 }
コード例 #12
0
        /// <summary>
        /// Create and start IM session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartIMSession(string imRemoteUri)
        {
            this.imRemoteUri = imRemoteUri;

            // Create IM session
            CreateSession(UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING);

            // Create remote participant
            UccUriManager uriManager = new UccUriManager();
            IUccSessionParticipant participant = this.imSession.CreateParticipant(uriManager.ParseUri(this.imRemoteUri), null);

            UccOperationContext context = new UccOperationContextClass();
            context.Initialize(operationId++, null);
            // Add remote participant
            this.imSession.AddParticipant(participant, context);
        }
コード例 #13
0
        /// <summary>
        /// Create and start AV session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartAVSession(string avRemoteUri)
        {
            this.avRemoteUri = avRemoteUri;

            // Create AV session
            CreateSession(UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO);

            // Create remote participant
            UccUriManager uriManager = new UccUriManager();
            IUccSessionParticipant participant = this.avSession.CreateParticipant(uriManager.ParseUri(this.avRemoteUri), null);
            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            // Create audio channel
            IUccMediaChannel channel = avParticipant.CreateChannel(UCC_MEDIA_TYPES.UCCMT_AUDIO, null);
            channel.PreferredMedia = (int)(UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE | UCC_MEDIA_DIRECTIONS.UCCMD_SEND);

            // Add channel
            avParticipant.AddChannel(channel);

            UccOperationContext context = new UccOperationContextClass();
            context.Initialize(operationId++, null);
            // Add remote participant
            this.avSession.AddParticipant(participant, context);
        }