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); }
public void OnOutgoingSession(IUccEndpoint pEventSource, UccOutgoingSessionEvent pEventData) { if (OutgoingSession != null) { OutgoingSession(pEventSource, pEventData); } }
void _IUccServerSignalingSettingsEvents.OnFindServer(IUccEndpoint eventSource, UccFindServerEvent eventData) { if (eventData.SignalingServers.Count > 0) { IUccSignalingServer server = eventData.SignalingServers[1] as IUccSignalingServer; foreach (IUccSignalingServer server1 in eventData.SignalingServers) { if (server1.TransportMode == UCC_TRANSPORT_MODE.UCCTM_TLS) { server = server1; } else if (server1.TransportMode == UCC_TRANSPORT_MODE.UCCTM_TCP && server.TransportMode == UCC_TRANSPORT_MODE.UCCTM_UDP) { server = server1; } } this.SetSignalingServer( new SignalingServer() { ServerAddress = server.ServerAddress, TransportMode = Helpers.Convert(server.TransportMode) }); this.endpoint.Enable(null); } else { this.CleanupEndpoint(); this.OnEnabled(new EndpointEventArgs(@"Can not find server, try to specify server address.")); } }
public void OnEnable(IUccEndpoint pEventSource, IUccOperationProgressEvent pEventData) { try { if (pEventData.IsComplete) { if (pEventData.StatusCode >= 0) { // Sign in succeeded. Proceed with subscription and publication. // Create a session manager object to handle session related functionality and events. this._sessionManager = pEventSource as IUccSessionManager; // Advise session manager instance of this class as endpoint sink. Advise <_IUccSessionManagerEvents>(this._sessionManager, this); PublishAvailability("Available"); } else { // Recover from failure to sign in. } } else { // Sign in failed. Make the endpoint null. pEventSource = null; } } catch (COMException ex) { throw ex; } }
/// <summary> /// Create Endpoint and associate to related events /// </summary> public void CreateEndpoint() { // Create endpoint UccUriManager uriManager = new UccUriManager(); this.endpoint = this.platform.CreateEndpoint(UCC_ENDPOINT_TYPE.UCCET_PRINCIPAL_SERVER_BASED, uriManager.ParseUri(uri), null, null); // Configure the endpoint IUccServerSignalingSettings settings = (IUccServerSignalingSettings)this.endpoint; // Add the credentials -- note: "*" means any realm UccCredential credential = settings.CredentialCache.CreateCredential(signName, password, domain); settings.CredentialCache.SetCredential("*", credential); // Set the server to use settings.Server = settings.CreateSignalingServer(serverName, (transport == "TCP")? UCC_TRANSPORT_MODE.UCCTM_TCP:UCC_TRANSPORT_MODE.UCCTM_TLS); // Set the allowed authentication modes settings.AllowedAuthenticationModes = (int)UCC_AUTHENTICATION_MODES.UCCAM_DIGEST; // Register this client to receive event // notifications when the login session changes. Advise <_IUccEndpointEvents>(this.endpoint, this); Advise <_IUccSessionManagerEvents>(this.endpoint, this); }
void _IUccEndpointEvents.OnDisable(IUccEndpoint eventSource, IUccOperationProgressEvent eventData) { if (eventData.IsComplete) { CleanupEndpoint(); this.IsDisabled = true; OnDisabled(new EndpointEventArgs(eventData)); } }
void _IUccSessionManagerEvents.OnOutgoingSession( IUccEndpoint eventSource, UccOutgoingSessionEvent eventData) { this.outSession = eventData.Session; this.sessionList.Add(eventData.Session); // register for generice events Advise <_IUccSessionEvents>(eventData.Session, this); Advise <_IUccSessionParticipantCollectionEvents>(eventData.Session, this); }
private void InitializeEndpoint(EndpointConfiguration configuration, AuthenticationMode authMode) { this.CleanupEndpoint(); // set vars if (Helpers.TryParseUri(Helpers.CorrectUri(configuration.Uri), out this.uri) == false) { throw new Exception("Sign-in address is not valid Uri"); } this.selfPresentity.SetUri(this.uri.Value); this.selfPresentityMonitor.SetUri(this.uri); this.disableImSessions = configuration.DisableImSessions; // platform events ComEvents.Advise <_IUccPlatformEvents>(this.platform, this); // create endpoint this.endpoint = this.platform.CreateEndpoint(UCC_ENDPOINT_TYPE.UCCET_PRINCIPAL_SERVER_BASED, this.uri, configuration.EndpoindIdString, null); ComEvents.Advise <_IUccEndpointEvents>(this.endpoint, this); ComEvents.Advise <_IUccSessionManagerEvents>(this.endpoint, this); // server signaling settings this.signalingSettings = (IUccServerSignalingSettings)this.endpoint; ComEvents.Advise <_IUccServerSignalingSettingsEvents>(this.signalingSettings, this); this.signalingSettings.AllowedAuthenticationModes = (int)authMode.ToUccAuthenticationMode(); UccCredential credential = authMode.IsDefaultCreditals() ? this.signalingSettings.CredentialCache.DefaultCredential : this.signalingSettings.CredentialCache.CreateCredential(configuration.Username, configuration.Password, null); this.signalingSettings.CredentialCache.SetCredential(configuration.Realm, credential); // media endpoint settings this.mediaEndpointSettings = (IUccMediaEndpointSettings)this.endpoint; ComEvents.Advise <_IUccMediaEndpointEvents>(this.endpoint, this); // create session manager this.sessionManager = (IUccSessionManager)this.endpoint; ComEvents.Advise <_IUccSessionManagerEvents>(this.sessionManager, this); // create user search manager this.userSearchManager = (IUccUserSearchManager)this.endpoint; }
/// <summary> /// Create Endpoint and associate to related events /// </summary> public void CreateEndpoint() { // Create endpoint UccUriManager uriManager = new UccUriManager(); this.endpoint = this.platform.CreateEndpoint(UCC_ENDPOINT_TYPE.UCCET_PRINCIPAL_SERVER_BASED, uriManager.ParseUri(uri), null, null); // Configure the endpoint IUccServerSignalingSettings settings = (IUccServerSignalingSettings)this.endpoint; // Add the credentials -- note: "*" means any realm UccCredential credential = settings.CredentialCache.CreateCredential(signName, password, domain); settings.CredentialCache.SetCredential("*", credential); // Set the server to use //settings.Server = settings.CreateSignalingServer(serverName, (transport == "TCP") ? UCC_TRANSPORT_MODE.UCCTM_TCP : UCC_TRANSPORT_MODE.UCCTM_TLS); settings.Server = settings.CreateSignalingServer(serverName, UCC_TRANSPORT_MODE.UCCTM_TCP); //settings. // Set the allowed authentication modes //settings.AllowedAuthenticationModes = (int)UCC_AUTHENTICATION_MODES.UCCAM_KERBEROS // | (int)UCC_AUTHENTICATION_MODES.UCCAM_NTLM; settings.AllowedAuthenticationModes = (int)UCC_AUTHENTICATION_MODES.UCCAM_DIGEST; // Register this client to receive event // notifications when the login session changes. Advise <_IUccEndpointEvents>(this.endpoint, this); //Advise<_IUcc>(this.endpoint, this); Advise <_IUccSessionManagerEvents>(this.endpoint, this); //Advise<IUccIncomingRequestEvent>(this.endpoint, this); //IUccSessionManager manager = (IUccSessionManager)this.endpoint; //manager.RegisterSessionDescriptionEvaluator(this); string proxyEndpointTelId = "tel:1234;phone-context=AB32-cdp.AB32-udp"; string proxyEndpointSipURI = "sip:[email protected]"; //proxyendpoint = this.platform.CreateProxyEndpoint(UCC_ENDPOINT_TYPE.UCCET_PROXY_TELEPHONY, endpoint, uriManager.ParseUri(uri), proxyEndpointTelId, null); // notifications when the login session changes. //Advise<_IUccEndpointEvents>(this.proxyendpoint, this); //Advise<_IUcc>(this.endpoint, this); //Advise<_IUccSessionManagerEvents>(this.proxyendpoint, this); }
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); } }
void _IUccEndpointEvents.OnEnable(IUccEndpoint eventSource, IUccOperationProgressEvent eventData) { if (eventData.IsComplete) { if (eventData.StatusCode >= 0) { this.IsEnabled = true; if (configuration.DisablePublicationsSubscriptions == false) { this.SelfSubscribe(); this.SelfPresentity.SetAvailability(this.loginAvailability); this.CreateSubscription(); this.Subscribe(this.Presentities); } // "sip:[email protected];gruu;opaque=srvr:MRAS:bMOjOHEFQiCtPh2g624vPAAA"; this.mediaEndpointSettings.FindMediaConnectivityServers( String.Format(@"sip:MRASLoc.{0}@{0}", this.uri.Host), null); } else { this.CleanupEndpoint(); } this.enableErrors.Add(new EndpointEventArgs(eventData, configuration.AuthenticationModes[enableErrors.Count])); if (((UInt32)eventData.StatusCode == Errors.UCC_E_SIP_STATUS_CLIENT_UNAUTHORIZED || (UInt32)eventData.StatusCode == Errors.UCC_E_SIP_AUTHENTICATION_TYPE_NOT_SUPPORTED || (UInt32)eventData.StatusCode == Errors.UCC_E_AUTHENTICATION_SERVER_UNAVAILABLE) //|| //(UInt32)eventData.StatusCode == Errors.opaque) && enableErrors.Count < configuration.AuthenticationModes.Length) { this.InternalBeginLogin(); } else { this.OnEnabled(); } } }
/// <summary> /// Display information when endpoint fires OnDisable event /// </summary> /// <param name="eventSource"></param> /// <param name="eventData"></param> void _IUccEndpointEvents.OnDisable( IUccEndpoint eventSource, IUccOperationProgressEvent eventData) { if (eventData.IsComplete) { if (eventData.StatusCode >= 0) { this.endpoint = null; this.mainForm.SetButtonsAfterLogout(); this.mainForm.WriteStatusMessage("User " + this.signName + " is logged out successfully."); } else { string formatMessage = string.Format("User {0} failed to logout. Error: {1}", this.signName, eventData.StatusCode.ToString("X")); this.mainForm.WriteStatusMessage(formatMessage); } } }
public void CleanupEndpoint() { foreach (var invite in this.AvInvites) { invite.Decline(); } foreach (Session session in this.Sessions) { session.UccSession = null; } this.IsDisabled = true; this.SelfPresentity.SetAvailability(AvailabilityValues.Unknown); ComEvents.UnadviseAll(this); this.selfPresentityMonitor.DestroyUccPresentity(); if (this.selfSubscription != null && this.selfSubscription.Presentities.Count > 0) { this.selfSubscription.Unsubscribe(null); } this.selfSubscription = null; foreach (Presentity presentity in this.Presentities) { presentity.DestroyUccPresentity(); } if (this.subscription != null && this.subscription.Presentities.Count > 0) { this.subscription.Unsubscribe(null); } this.subscription = null; this.signalingSettings = null; this.mediaEndpointSettings = null; this.userSearchManager = null; this.endpoint = null; }
void _IUccSessionManagerEvents.OnOutgoingSession( IUccEndpoint eventSource, UccOutgoingSessionEvent eventData) { }
/// <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(); }
void _IUccSessionManagerEvents.OnOutgoingSession( IUccEndpoint eventSource, UccOutgoingSessionEvent eventData) { this.outSession = eventData.Session; this.sessionList.Add(eventData.Session); // register for generice events Advise<_IUccSessionEvents>(eventData.Session, this); Advise<_IUccSessionParticipantCollectionEvents>(eventData.Session, this); }
public void OnDisable(IUccEndpoint pEventSource, IUccOperationProgressEvent pEventData) { }
/// <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(); }