private void ManageRoster() { if (!rainbowApplication.IsConnected()) { return; } string id = contact_id.StringValue; if (!String.IsNullOrEmpty(id)) { Contact contact = rainbowContacts.GetContactFromContactId(id); if (contact == null) { // We want to add it to the roster Invitations invit = rainbowApplication.GetInvitations(); invit.SendInvitationByContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Invitation sent to this contact [{id}]"); } else { string logline = String.Format("Impossible to send an invitation to this contact [{1}]:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logline); log.Warn(logline); } }); } else { // We cant to remove from the roster rainbowContacts.RemoveFromContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Contact [{id}] has been removed from your roster"); } else { string logline = String.Format("Impossible to remove this contact [{1}] from your roster:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logline); log.Warn(logline); } }); } } }
private void btnRosterAddRemove_Click(object sender, EventArgs e) { if (!rainbowApplication.IsConnected()) { return; } String id = tbContactId.Text; if (!String.IsNullOrEmpty(id)) { Contact contact = rainbowContacts.GetContactFromContactId(id); if (contact == null) { // We want to add it in the roster Invitations invitations = rainbowApplication.GetInvitations(); invitations.SendInvitationByContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Invitation sent successfully to this contact [{id}]"); } else { string logLine = String.Format("Impossible to send invitation to this contact [{1}]:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logLine); log.LogInformation(logLine); } }); } else { // We want to remove it from the roster rainbowContacts.RemoveFromContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Contact [{id}] has been removed from your roster"); } else { string logLine = String.Format("Impossible to remove this contact [{1}] from your roster:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logLine); log.LogInformation(logLine); } }); } } }