public void HandleAuthorizationsRequest(VsJid id) { var to = XmppIdConverter.Convert(id); var name = GetInterlocutor(id).Name; _queue.PushToFront(new AuthorizationRequestMessage( name, () => _presenceManager.ApproveSubscriptionRequest(to), () => _presenceManager.RefuseSubscriptionRequest(to))); }
public void SendMessage(Interlocutor interlocutor, Message message) { var outMessage = new agsXMPP.protocol.client.Message(); outMessage.To = XmppIdConverter.Convert(interlocutor.Id); outMessage.Body = message.Body; outMessage.Type = agsXMPP.protocol.client.MessageType.chat; _connection.Send(outMessage); message.From = Client.Id; message.To = interlocutor.Id; message.Date = DateTime.Now; interlocutor.History.Add(message); }
public static RosterInfo Create(RosterItem item) { bool isSubscribed = item.Subscription == SubscriptionType.both || item.Subscription == SubscriptionType.to; var name = string.IsNullOrEmpty(item.Name) ? item.Jid.User : item.Name; var id = XmppIdConverter.Convert(item.Jid); return(new RosterInfo { Id = id, Name = name, ImName = item.Jid.Resource, Subscribed = isSubscribed }); }
private void OnPresence(object sender, Presence pres) { var from = XmppIdConverter.Convert(pres.From); _listener.ChangedState(from, pres.ParseState()); if (!string.IsNullOrEmpty(pres.From.Resource)) { _listener.UpdatedImName(from, pres.From.Resource); } if (pres.Type == PresenceType.subscribe) { _listener.RequestsAuthorization(from); } }
private void OnRosterItem(object sender, RosterItem item) { var vsId = XmppIdConverter.Convert(item.Jid); if (_container.Contains(vsId) && item.Subscription == SubscriptionType.remove) { _listener.RemoveInterlocutor(vsId); } else if (_container.Contains(vsId) && item.Subscription != SubscriptionType.remove) { _listener.UpdateInterlocutor(RosterInfo.Create(item)); } else if (!_container.Contains(vsId) && item.Subscription != SubscriptionType.remove) { _listener.CreateInterlocutor(RosterInfo.Create(item)); } }
private void OnMessage(object sender, agsXMPP.protocol.client.Message msg) { var interlocutor = _client.Contacts.SingleOrDefault(contact => contact.Id == XmppIdConverter.Convert(msg.From)); if (interlocutor == null || string.IsNullOrEmpty(msg.Body)) { return; } interlocutor.History.Add(new Message { Body = msg.Body, Date = DateTime.Now, From = interlocutor.Id, To = Client.Id, Type = interlocutor.ImName == RESOURCE_NAME ? MessageType.Xaml : MessageType.Text }); interlocutor.HasUnreadMessages = true; }
private void OnLogin(object sender) { _client.State = ClientState.Connected; _client.Id = XmppIdConverter.Convert(_connection.MyJID); }
public void RemoveContact(Interlocutor interlocutor) { _rosterManager.RemoveRosterItem(XmppIdConverter.Convert(interlocutor.Id)); //not waiting responce after RemoveRosterItem executed Client.Contacts.Remove(interlocutor); }
public void PushAuthorizationsRequest(VsJid id) { var to = XmppIdConverter.Convert(id); _presenceManager.Subscribe(to); }