public static void Initialize() { try { _client = LyncClient.GetClient(); LyncContactManager = _client.ContactManager; } catch (ClientNotFoundException clne) { throw new Exception("Ensure Lync client is installed and is configured to run in Full UI suppression mode", clne); } if (!_client.InSuppressedMode) { throw new ApplicationException("Ensure Lync client is configured to run in Full UI suppression mode"); } if (_client.State != ClientState.Uninitialized) { throw new ApplicationException(string.Format("Client is in state '{0}', expected '{1}'", _client.State, ClientState.Uninitialized)); } _client.EndInitialize(_client.BeginInitialize(null, null)); _client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; _client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved; }
private void LoginInit() { //1) Register for the three Lync client events needed so that application is notified when: // * Lync client signs in or out _LyncClient.StateChanged += new EventHandler <ClientStateChangedEventArgs>(_LyncClient_StateChanged); _LyncClient.SignInDelayed += new EventHandler <SignInDelayedEventArgs>(_LyncClient_SignInDelayed); _LyncClient.CredentialRequested += new EventHandler <CredentialRequestedEventArgs>(_LyncClient_CredentialRequested); //2-4) Client state of uninitialized means that Lync is configured for UI suppression mode and //must be initialized before a user can sign in to Lync if (_LyncClient.State == ClientState.Uninitialized) { _LyncClient.BeginInitialize( (ar) => { _LyncClient.EndInitialize(ar); //_thisProcessInitializedLync = true; }, null); } //5) If the Lync client is signed out, sign into the Lync client else if (_LyncClient.State == ClientState.SignedOut) { SignUserIn(); } //6) A sign in operation is pending else if (_LyncClient.State == ClientState.SigningIn) { } else if (_LyncClient.State == ClientState.SignedIn) { } }
public void SignIn(string signInAddress, string username, string password) { _signInAddress = signInAddress; _username = username; _password = password; if ((_lyncClient == null)) { return; } try { //2-4) Client state of uninitialized means that Lync Is configured for UI suppression mode And //must be initialized before a user can sign in to Lync if (_lyncClient.State == ClientState.Uninitialized) { Trace.WriteLine("SignIn: ClientState.Uninitialized"); _lyncClient.BeginInitialize(ar => { _lyncClient.EndInitialize(ar); _thisProcessInitializedLync = true; }, null); //If the Lync client Is signed out, sign into the Lync client } else if ((_lyncClient.State == ClientState.SignedOut)) { Trace.WriteLine("SignIn: ClientState.SignedOut"); SignUserIn(); } else if ((_lyncClient.State == ClientState.SigningIn) || _lyncClient.State == ClientState.SignedIn) { Trace.WriteLine($"SignIn: ClientState.SigningIn ({ClientState.SigningIn}) || ClientState.SignedIn ({ClientState.SignedIn})"); Trace.WriteLine($"SignIn: {_lyncClient.State}"); SignOut(); SignUserIn(); } if ((!_signInProcedureEvent.WaitOne(75000))) { //signIn timeout occured TimeoutOccured = true; } } catch (Exception ex) { Trace.WriteLine($"Generic Exception during SignIn {ex.Message}"); } }
private void Window_Loaded_1(object sender, RoutedEventArgs e) { try { _client = LyncClient.GetClient(); _client.StateChanged += client_StateChanged; StatusTextBlock.Text = _client.State.ToString(); if (_client.InSuppressedMode) { _client.BeginInitialize((ar) => { _client.EndInitialize(ar); }, null); } _client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; } catch (Exception ex) { StatusTextBlock.Text = "Exception: " + ex.Message; } }
/// <summary> /// Sign in to Lync Client if not signed in. /// </summary> public void SignInAndGetAvailability() { try { // Get Lync Client and Contact Manager. lyncClient = LyncClient.GetClient(); // Register for the client state changed event lyncClient.StateChanged += lyncClient_StateChanged; //If lync client is Uninitialized then first initialize it. if (lyncClient.State == ClientState.Uninitialized) { lyncClient.BeginInitialize((ar) => { lyncClient.EndInitialize(ar); }, null); } // If lync client is signed out then let sign in user first. else if (lyncClient.State == ClientState.SignedOut) { SignUserIntoLync(); } // If user already signed in then get user list with their presence status. else if (lyncClient.State == ClientState.SignedIn) { BindOnlineUsers(); } } catch (ClientNotFoundException) { MessageBox.Show("Lync is not running on this computer"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void InitializeCallback(IAsyncResult ar) { Log("Initialize Callback, calling EndInitialize()"); lyncClient.EndInitialize(ar); }
public void InitWithoutSignIn() { try { if (_lyncClient == null) { //If sideBySide == false, a standard endpoint is created //Otherwise, a side-by-side endpoint is created _lyncClient = LyncClient.GetClient(false); _log.Info("Connect _lyncClientState:{0}", _lyncClient.State.ToString()); } //Display the current state of the Lync client. if (ClientStateChanged != null) { ClientStateChanged(_lyncClient.State.ToString()); } //Register for the three Lync client events needed so that application is notified when: // * Lync client signs in or out _lyncClient.StateChanged += OnLyncClientStateChanged; //Client state of uninitialized means that Lync is configured for UI suppression mode and //must be initialized before a user can sign in to Lync if (_lyncClient.State == ClientState.Uninitialized) { _lyncClient.BeginInitialize( (ar) => { _lyncClient.EndInitialize(ar); _thisProcessInitializedLync = true; }, null); } else if (_lyncClient.State == ClientState.SignedIn) { } //If the Lync client is signed out, sign into the Lync client else if (_lyncClient.State == ClientState.SignedOut) { } else if (_lyncClient.State == ClientState.SigningIn) { } } catch (NotInitializedException ni) { _log.ErrorException("Connect", ni); } catch (ClientNotFoundException cnf) { _log.ErrorException("Connect", cnf); } catch (Exception exc) { _log.ErrorException("Connect", exc); } }
/// <summary> /// Gets the Lync client, initializes if in UI suppression, and /// starts the user sign in process. This method can raise exceptions /// which are thrown if the calling form has not registered a callback for /// exception specific events that are declared in this class. /// </summary> /// <param name="sideBySide">bool. Specifies endpoint mode</param> public void Connect(string userUrl, string password, bool sideBySide) { //Calling GetClient a second time in a running process will //return the previously cached client. For example, calling GetClient(bool sideBySideFlag) // the first time in a process returns a new endpoint. Calling the method a second //time returns the original endpoint. If you call GetClient(false) to get a client //endpoint and then GetClient(true), the original client enpoint is returned even though // a true value argument is passed with the second call. try { _userUri = userUrl; _userPassword = password; _log.Info("Connect userUrl:{0}", userUrl); if (_lyncClient == null) { //If sideBySide == false, a standard endpoint is created //Otherwise, a side-by-side endpoint is created _lyncClient = LyncClient.GetClient(sideBySide); _log.Info("Connect _lyncClientState:{0}", _lyncClient.State.ToString()); } _inSideBySideMode = sideBySide; //Display the current state of the Lync client. if (ClientStateChanged != null) { ClientStateChanged(_lyncClient.State.ToString()); } //Register for the three Lync client events needed so that application is notified when: // * Lync client signs in or out _lyncClient.StateChanged += OnLyncClientStateChanged; _lyncClient.SignInDelayed += OnLyncClientSignInDelayed; _lyncClient.CredentialRequested += OnLyncClientCredentialRequested; //Client state of uninitialized means that Lync is configured for UI suppression mode and //must be initialized before a user can sign in to Lync if (_lyncClient.State == ClientState.Uninitialized) { _lyncClient.BeginInitialize( (ar) => { _lyncClient.EndInitialize(ar); _thisProcessInitializedLync = true; }, null); } else if (_lyncClient.State == ClientState.SignedIn) { if (UserIsSignedIn != null) { UserIsSignedIn(_lyncClient); } } //If the Lync client is signed out, sign into the Lync client else if (_lyncClient.State == ClientState.SignedOut) { SignUserIn(); } else if (_lyncClient.State == ClientState.SigningIn) { } } catch (NotInitializedException ni) { _log.ErrorException("Connect", ni); } catch (ClientNotFoundException cnf) { _log.ErrorException("Connect", cnf); } catch (Exception exc) { _log.ErrorException("Connect", exc); } }
public static void Initialize() { try { _client = LyncClient.GetClient(); LyncContactManager = _client.ContactManager; } catch (ClientNotFoundException clne) { throw new Exception("Ensure Lync client is installed and is configured to run in Full UI suppression mode", clne); } if (!_client.InSuppressedMode) throw new ApplicationException("Ensure Lync client is configured to run in Full UI suppression mode"); if (_client.State != ClientState.Uninitialized) throw new ApplicationException(string.Format("Client is in state '{0}', expected '{1}'", _client.State, ClientState.Uninitialized)); _client.EndInitialize(_client.BeginInitialize(null, null)); _client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; _client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved; }