public void OnIncomingSession(IUccEndpoint pEventSource, UccIncomingSessionEvent pEventData) { pEventData.Accept(); var session = pEventData.Session as IUccSession; if (!this._sessions.ContainsKey(pEventData.Inviter.Uri.Value.ToLower())) { this._sessions.Add(pEventData.Inviter.Uri.Value.ToLower(), session); } else { this._sessions[pEventData.Inviter.Uri.Value.ToLower()] = session; } foreach (var p in pEventData.Session.Participants) { Advise <_IUccInstantMessagingSessionParticipantEvents>(p, this); } //pEventData.Inviter.Uri.Value //if (IncomingSession != null) // IncomingSession(pEventSource, pEventData); }
protected void Dispose() { eventData = null; createSession = null; if (timer != null) { timer.Stop(); timer.Dispose(); timer = null; } }
public AvInvite(IPresentity inviter, int timeout, UccIncomingSessionEvent eventData, CreateSessionDelegate createSession) { this.Created = DateTime.Now; this.state = AvInviteState.Pending; this.Accepted = false; this.timer = new Timer(); this.timer.AutoReset = false; this.timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); this.timer.Interval = 1000 * timeout; this.timer.Start(); this.inviter = inviter; this.eventData = eventData; this.createSession = createSession; }
void _IUccSessionManagerEvents.OnIncomingSession(IUccEndpoint eventSource, UccIncomingSessionEvent eventData) { if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING) { if (disableImSessions) { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_NOT_ACCEPTABLE); } else { ISession session = null; if (eventData.Session.Participants.Count == 2) { session = this.FindSession(SessionType.ImSession, eventData.Inviter.Uri.Value); if (session != null) { (session as Session).UccSession = eventData.Session; } } if (session == null) { session = this.CreateSession(eventData.Session); } eventData.Accept(); } } else if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO) { AvInvite eventArgs = new AvInvite(this.GetPresentity(eventData.Inviter.Uri.Value), this.configuration.AvInviteTimeout, eventData, (uccSession) => { this.CreateSession(uccSession); }); AvInvites.Add(eventArgs); OnEvent <AvInvite>(IncommingAvSession, eventArgs); } else { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_NOT_ACCEPTABLE); } }
/// <summary> /// Process Incoming Session request /// </summary> /// <param name="eventSource"></param> /// <param name="eventData"></param> void _IUccSessionManagerEvents.OnIncomingSession( IUccEndpoint eventSource, UccIncomingSessionEvent eventData) { DialogResult result; // Handle incoming IM session if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING) { // The App only support one active IM session. Reject incoming IM session request // if there is already an active IM session. if (this.imSession != null) { MessageBox.Show("There is an active IM session. This Application only supports one active IM session right now. " + "The App is rejecting incoming session from " + eventData.Inviter.Uri + "."); eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Ask user he wants to accept the incoming requet. result = MessageBox.Show("Accept incoming IM session from " + eventData.Inviter.Uri + "?", "Incoming Session", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Register to receive events this.imSession = eventData.Session; this.imRemoteUri = eventData.Inviter.Uri.AddressOfRecord; Advise <_IUccInstantMessagingSessionEvents>(this.imSession, this); foreach (IUccSessionParticipant oneParticipant in this.imSession.Participants) { if (oneParticipant != null && !oneParticipant.IsLocal) { Advise <_IUccInstantMessagingSessionParticipantEvents>(oneParticipant, this); Advise <_IUccSessionParticipantEvents>(oneParticipant, this); } } } // Handle incoming AV session else if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO) { // Reject incoming AV session request if there is already an active av session. if (this.avSession != null) { MessageBox.Show("There is an AV active session. We only supports one active session right now. " + "The App is rejecting incoming session from " + eventData.Inviter.Uri + "."); eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } result = MessageBox.Show("Accept incoming AV session from " + eventData.Inviter.Uri + "?", "Incoming Session", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Register to receive events this.avRemoteUri = eventData.Inviter.Uri.AddressOfRecord; this.avSession = eventData.Session; foreach (IUccSessionParticipant oneParticipant in this.avSession.Participants) { if (oneParticipant != null && !oneParticipant.IsLocal) { Advise <_IUccSessionParticipantEvents>(oneParticipant, this); } } } else { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // register for generice events Advise <_IUccSessionEvents>(eventData.Session, this); Advise <_IUccSessionParticipantCollectionEvents>(eventData.Session, this); // Accept incoming session eventData.Accept(); }
/// <summary> /// Process Incoming Session request /// </summary> /// <param name="eventSource"></param> /// <param name="eventData"></param> void _IUccSessionManagerEvents.OnIncomingSession( IUccEndpoint eventSource, UccIncomingSessionEvent eventData) { DialogResult result; // Handle incoming IM session //eventSource. if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING) { // The App only support one active IM session. Reject incoming IM session request // if there is already an active IM session. if (this.imSession != null) { MessageBox.Show("There is an active IM session. This Application only supports one active IM session right now. " + "The App is rejecting incoming session from " + eventData.Inviter.Uri + "."); eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Ask user he wants to accept the incoming requet. result = MessageBox.Show("Accept incoming IM session from " + eventData.Inviter.Uri + "?", "Incoming Session", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Register to receive events this.imSession = eventData.Session; this.imRemoteUri = eventData.Inviter.Uri.AddressOfRecord; Advise<_IUccInstantMessagingSessionEvents>(this.imSession, this); foreach (IUccSessionParticipant oneParticipant in this.imSession.Participants) { if (oneParticipant != null && !oneParticipant.IsLocal) { Advise<_IUccInstantMessagingSessionParticipantEvents>(oneParticipant, this); Advise<_IUccSessionParticipantEvents>(oneParticipant, this); } } } // Handle incoming AV session else if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO) { //SetupAudioMicro(); // Reject incoming AV session request if there is already an active av session. if (this.avSession != null) { MessageBox.Show("There is an AV active session. We only supports one active session right now. " + "The App is rejecting incoming session from " + eventData.Inviter.Uri + "."); eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } //IUccSessionCallControl aa = eventData.Session as IUccSessionCallControl; //aa. //eventSource. result = MessageBox.Show("Accept incoming AV session from " + eventData.Inviter.Uri.User + "?", "Incoming Session", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // Register to receive events this.avRemoteUri = eventData.Inviter.Uri.AddressOfRecord; this.avSession = eventData.Session; foreach (IUccSessionParticipant oneParticipant in this.avSession.Participants) { if (oneParticipant != null && !oneParticipant.IsLocal) { Advise<_IUccSessionParticipantEvents>(oneParticipant, this); } } } else { eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE); return; } // register for generice events Advise<_IUccSessionEvents>(eventData.Session, this); Advise<_IUccSessionParticipantCollectionEvents>(eventData.Session, this); // Accept incoming session eventData.Accept(); }