private void btnLoginLogout_Click(object sender, EventArgs e) { if (rainbowApplication.IsConnected()) { // We want to logout rainbowApplication.Logout(callback => { if (!callback.Result.Success) { string logLine = String.Format("Impossible to logout:\r\n{0}", Util.SerializeSdkError(callback.Result)); AddStateLine(logLine); log.LogWarning(logLine); } }); } else { // Check event mode used: if (cbUseS2SEventMode.Checked) { // We want to use S2S Event mode rainbowApplication.Restrictions.EventMode = Restrictions.SDKEventMode.S2S; // We must specify also the callback URL String callbackUrl = tbCallbackUrl.Text; rainbowApplication.SetS2SCallbackUrl(callbackUrl); // We must also create and start a local web server - here we use 9870 for our local web server if (webServer == null) { webServer = CreateWebServer("http://localhost:9870", callbackUrl); webServer.RunAsync(); } } else { // We use XMMPP mode (std mode) rainbowApplication.Restrictions.EventMode = Restrictions.SDKEventMode.XMPP; } String login = tbLogin.Text; String password = tbPassword.Text; // We want to login rainbowApplication.Login(login, password, callback => { if (callback.Result.Success) { // Since we are connected, we get the current contact object rainbowMyContact = rainbowContacts.GetCurrentContact(); } else { string logLine = String.Format("Impossible to login:\r\n{0}", Util.SerializeSdkError(callback.Result)); AddStateLine(logLine); log.LogWarning(logLine); } }); } }