本文整理汇总了Java中org.xmpp.packet.Roster类的典型用法代码示例。如果您正苦于以下问题:Java Roster类的具体用法?Java Roster怎么用?Java Roster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Roster类属于org.xmpp.packet包,在下文中一共展示了Roster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setName
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Sets the name of the group. Changing the group's name is like moving all
* the group entries of the group to a new group specified by the new name.
* Since this group won't have entries it will be removed from the roster.
* This means that all the references to this object will be invalid and
* will need to be updated to the new group specified by the new name.
*
* @param name
* the name of the group.
*/
public void setName(String name) {
synchronized (entries) {
for (RosterEntry entry : entries) {
Roster packet = new Roster();
packet.setType(IQ.Type.set);
List<String> groupNames = new LinkedList<String>(
entry.getGroupNames());
groupNames.remove(this.name);
groupNames.add(name);
packet.addItem(new JID(entry.getUser()), entry.getName(),
entry.getAsk(), entry.getSubscription(), groupNames);
connection.sendPacket(packet);
}
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:26,代码来源:RosterGroup.java
示例2: reload
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Reloads the entire roster from the server. This is an asynchronous
* operation, which means the method will return immediately, and the roster
* will be reloaded at a later point when the server responds to the reload
* request.
*
* @throws IllegalStateException
* if connection is not logged in or logged in anonymously
*/
public void reload() {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Not logged in to server.");
}
if (connection.isAnonymous()) {
throw new IllegalStateException(
"Anonymous users can't have a roster.");
}
Roster packet = new Roster();
if (rosterStore != null && connection.isRosterVersioningSupported()) {
packet.getElement().element("query")
.addAttribute("ver", rosterStore.getRosterVersion());
PacketFilter filter = new PacketIDFilter(packet.getID());
connection.addPacketListener(new RosterResultListener(), filter);
}
connection.sendPacket(packet);
}
开发者ID:abmargb,项目名称:jamppa,代码行数:28,代码来源:UserRoster.java
示例3: processPushItem
import org.xmpp.packet.Roster; //导入依赖的package包/类
private void processPushItem(Collection<String> addedEntries,
Collection<String> updatedEntries,
Collection<String> deletedEntries, String version, Item item) {
RosterEntry entry = new RosterEntry(item.getJID().toBareJID(),
item.getName(), item.getSubscription(), item.getAsk(),
UserRoster.this, connection);
if (item.getSubscription().equals(Roster.Subscription.remove)) {
deleteEntry(deletedEntries, entry);
if (rosterStore != null) {
rosterStore.removeEntry(entry.getUser(), version);
}
} else if (hasValidSubscriptionType(item)) {
addUpdateEntry(addedEntries, updatedEntries, item, entry);
if (rosterStore != null) {
rosterStore.addEntry(item, version);
}
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:20,代码来源:UserRoster.java
示例4: parseIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
private IQ parseIQ(Element doc) {
Element pingEl = doc.element(Ping.ELEMENT);
if (pingEl != null
&& pingEl.getNamespace().getURI().equals(Ping.NAMESPACE)) {
return new Ping(doc);
}
Element bindEl = doc.element(Bind.ELEMENT);
if (bindEl != null
&& bindEl.getNamespace().getURI().equals(Bind.NAMESPACE)) {
return new Bind(doc);
}
Element query = doc.element("query");
if (query != null) {
if ("jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
}
if ("jabber:iq:auth".equals(query.getNamespaceURI())) {
return new Authentication(doc);
}
}
return new IQ(doc);
}
开发者ID:abmargb,项目名称:jamppa,代码行数:26,代码来源:PacketReader.java
示例5: getIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* 获取IQ
*
* @param doc
* @return
*/
private IQ getIQ(Element doc) {
Element query = doc.element("query");
if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
} else {
return new IQ(doc, false);
}
}
开发者ID:lijian17,项目名称:androidpn-server,代码行数:15,代码来源:StanzaHandler.java
示例6: getIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
private IQ getIQ(Element doc) {
Element query = doc.element("query");
if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
}
else {
return new IQ(doc);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:SocketReader.java
示例7: getIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
private IQ getIQ(Element doc) {
Element query = doc.element("query");
if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
} else {
return new IQ(doc, false);
}
}
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:9,代码来源:StanzaHandler.java
示例8: getIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
private IQ getIQ(Element doc) {
Element query = doc.element("query");
if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
} else {
return new IQ(doc, !validateJIDs());
}
}
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:9,代码来源:StanzaHandler.java
示例9: getIQ
import org.xmpp.packet.Roster; //导入依赖的package包/类
private IQ getIQ(Element doc) {
Element query = doc.element("query");
if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
return new Roster(doc);
}
else {
return new IQ(doc, !validateJIDs());
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:10,代码来源:StanzaHandler.java
示例10: setName
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Sets the name associated with this entry.
*
* @param name
* the name.
*/
public void setName(String name) {
// Do nothing if the name hasn't changed.
if (name != null && name.equals(this.name)) {
return;
}
this.name = name;
Roster packet = new Roster();
packet.setType(IQ.Type.set);
packet.addItem(new JID(user), name, ask, subscription, getGroupNames());
connection.sendPacket(packet);
}
开发者ID:abmargb,项目名称:jamppa,代码行数:18,代码来源:RosterEntry.java
示例11: addEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Adds a roster entry to this group. If the entry was unfiled then it will
* be removed from the unfiled list and will be added to this group. Note
* that this is an asynchronous call -- Smack must wait for the server to
* receive the updated roster.
*
* @param entry
* a roster entry.
* @throws XMPPException
* if an error occured while trying to add the entry to the
* group.
*/
public void addEntry(RosterEntry entry) throws XMPPException {
PacketCollector collector = null;
// Only add the entry if it isn't already in the list.
synchronized (entries) {
if (!entries.contains(entry)) {
Roster packet = new Roster();
packet.setType(IQ.Type.set);
List<String> groupNames = new LinkedList<String>(
entry.getGroupNames());
groupNames.add(getName());
packet.addItem(new JID(entry.getUser()), entry.getName(),
entry.getAsk(), entry.getSubscription(), groupNames);
// Wait up to a certain number of seconds for a reply from the
// server.
collector = connection
.createPacketCollector(new PacketIDFilter(packet
.getID()));
connection.sendPacket(packet);
}
}
if (collector != null) {
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
collector.cancel();
if (response == null) {
throw new XMPPException("No response from the server.");
}
// If the server replied with an error, throw an exception.
else if (response.getType() == IQ.Type.error) {
throw new XMPPException(response.getError());
}
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:46,代码来源:RosterGroup.java
示例12: removeEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Removes a roster entry from this group. If the entry does not belong to
* any other group then it will be considered as unfiled, therefore it will
* be added to the list of unfiled entries. Note that this is an
* asynchronous call -- Smack must wait for the server to receive the
* updated roster.
*
* @param entry
* a roster entry.
* @throws XMPPException
* if an error occured while trying to remove the entry from the
* group.
*/
public void removeEntry(RosterEntry entry) throws XMPPException {
PacketCollector collector = null;
// Only remove the entry if it's in the entry list.
// Remove the entry locally, if we wait for
// RosterPacketListenerprocess>>Packet(Packet)
// to take place the entry will exist in the group until a packet is
// received from the
// server.
synchronized (entries) {
if (entries.contains(entry)) {
Roster packet = new Roster();
packet.setType(IQ.Type.set);
List<String> groupNames = new LinkedList<String>(
entry.getGroupNames());
groupNames.remove(this.getName());
packet.addItem(new JID(entry.getUser()), entry.getName(),
entry.getAsk(), entry.getSubscription(), groupNames);
// Wait up to a certain number of seconds for a reply from the
// server.
collector = connection
.createPacketCollector(new PacketIDFilter(packet
.getID()));
connection.sendPacket(packet);
}
}
if (collector != null) {
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
collector.cancel();
if (response == null) {
throw new XMPPException("No response from the server.");
}
// If the server replied with an error, throw an exception.
else if (response.getType() == IQ.Type.error) {
throw new XMPPException(response.getError());
}
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:52,代码来源:RosterGroup.java
示例13: getEntries
import org.xmpp.packet.Roster; //导入依赖的package包/类
@Override
public List<Item> getEntries() {
List<Item> entries = new ArrayList<Roster.Item>();
for (File file : fileDir.listFiles(rosterDirFilter)) {
Item entry = readEntry(file);
if (entry == null) {
log("Roster store file '" + file + "' is invalid.");
} else {
entries.add(entry);
}
}
return entries;
}
开发者ID:abmargb,项目名称:jamppa,代码行数:16,代码来源:DefaultRosterStore.java
示例14: createEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Creates a new roster entry and presence subscription. The server will
* asynchronously update the roster with the subscription status.
*
* @param user
* the user. (e.g. [email protected])
* @param name
* the nickname of the user.
* @param groups
* the list of group names the entry will belong to, or
* <tt>null</tt> if the the roster entry won't belong to a group.
* @throws XMPPException
* if an XMPP exception occurs.
* @throws IllegalStateException
* if connection is not logged in or logged in anonymously
*/
public void createEntry(String user, String name, String[] groups)
throws XMPPException {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Not logged in to server.");
}
if (connection.isAnonymous()) {
throw new IllegalStateException(
"Anonymous users can't have a roster.");
}
// Create and send roster entry creation packet.
Roster rosterPacket = new Roster();
rosterPacket.setType(IQ.Type.set);
rosterPacket.addItem(new JID(user), name, null, null,
Arrays.asList(groups));
// Wait up to a certain number of seconds for a reply from the server.
PacketCollector collector = connection
.createPacketCollector(new PacketIDFilter(rosterPacket.getID()));
connection.sendPacket(rosterPacket);
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
collector.cancel();
if (response == null) {
throw new XMPPException("No response from the server.");
}
// If the server replied with an error, throw an exception.
else if (response.getType() == IQ.Type.error) {
throw new XMPPException(response.getError());
}
// Create a presence subscription packet and send.
Presence presencePacket = new Presence(Presence.Type.subscribe);
presencePacket.setTo(user);
connection.sendPacket(presencePacket);
}
开发者ID:abmargb,项目名称:jamppa,代码行数:52,代码来源:UserRoster.java
示例15: removeEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* Removes a roster entry from the roster. The roster entry will also be
* removed from the unfiled entries or from any roster group where it could
* belong and will no longer be part of the roster. Note that this is an
* asynchronous call -- Smack must wait for the server to send an updated
* subscription status.
*
* @param entry
* a roster entry.
* @throws XMPPException
* if an XMPP error occurs.
* @throws IllegalStateException
* if connection is not logged in or logged in anonymously
*/
public void removeEntry(RosterEntry entry) throws XMPPException {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Not logged in to server.");
}
if (connection.isAnonymous()) {
throw new IllegalStateException(
"Anonymous users can't have a roster.");
}
// Only remove the entry if it's in the entry list.
// The actual removal logic takes place in
// RosterPacketListenerprocess>>Packet(Packet)
if (!entries.containsKey(entry.getUser())) {
return;
}
Roster packet = new Roster();
packet.setType(IQ.Type.set);
packet.addItem(new JID(entry.getUser()), entry.getName(),
entry.getAsk(), Subscription.remove, entry.getGroupNames());
PacketCollector collector = connection
.createPacketCollector(new PacketIDFilter(packet.getID()));
connection.sendPacket(packet);
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
collector.cancel();
if (response == null) {
throw new XMPPException("No response from the server.");
}
// If the server replied with an error, throw an exception.
else if (response.getType() == IQ.Type.error) {
throw new XMPPException(response.getError());
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:48,代码来源:UserRoster.java
示例16: processPacket
import org.xmpp.packet.Roster; //导入依赖的package包/类
@Override
public void processPacket(Packet packet) {
connection.removePacketListener(this);
if (packet instanceof Roster) {
// Non-empty roster results are processed by the
// RosterPacketListener class
return;
}
if (!(packet instanceof IQ)) {
return;
}
IQ result = (IQ) packet;
if (result.getType().equals(IQ.Type.result)) {
Collection<String> addedEntries = new ArrayList<String>();
Collection<String> updatedEntries = new ArrayList<String>();
for (Roster.Item item : rosterStore.getEntries()) {
RosterEntry entry = new RosterEntry(item.getJID()
.toBareJID(), item.getName(),
item.getSubscription(), item.getAsk(),
UserRoster.this, connection);
addUpdateEntry(addedEntries, updatedEntries, item, entry);
}
synchronized (UserRoster.this) {
rosterInitialized = true;
UserRoster.this.notifyAll();
}
fireRosterChangedEvent(addedEntries, updatedEntries,
Collections.<String> emptyList());
}
}
开发者ID:abmargb,项目名称:jamppa,代码行数:32,代码来源:UserRoster.java
示例17: hasValidSubscriptionType
import org.xmpp.packet.Roster; //导入依赖的package包/类
private boolean hasValidSubscriptionType(Roster.Item item) {
return item.getSubscription().equals(Roster.Subscription.none)
|| item.getSubscription().equals(Roster.Subscription.from)
|| item.getSubscription().equals(Roster.Subscription.to)
|| item.getSubscription().equals(Roster.Subscription.both);
}
开发者ID:abmargb,项目名称:jamppa,代码行数:7,代码来源:UserRoster.java
示例18: getEntries
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* This method returns a collection of all roster items contained in this
* store.
*
* @return List of {@link RosterEntry}
*/
public Collection<Roster.Item> getEntries();
开发者ID:abmargb,项目名称:jamppa,代码行数:8,代码来源:RosterStore.java
示例19: getEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* This method returns the roster item in this store for the given JID.
*
* @param bareJid
* The bare JID of the RosterEntry
* @return The {@link RosterEntry} which belongs to that user
*/
public Roster.Item getEntry(String bareJid);
开发者ID:abmargb,项目名称:jamppa,代码行数:9,代码来源:RosterStore.java
示例20: addEntry
import org.xmpp.packet.Roster; //导入依赖的package包/类
/**
* This method stores a new roster entry in this store or updates an
* existing one.
*
* @param item
* the entry to store
* @param version
* the new roster version
* @return True if successful
*/
public boolean addEntry(Roster.Item item, String version);
开发者ID:abmargb,项目名称:jamppa,代码行数:12,代码来源:RosterStore.java
注:本文中的org.xmpp.packet.Roster类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论