当前位置: 首页>>代码示例>>Java>>正文


Java StanzaFilter类代码示例

本文整理汇总了Java中org.jivesoftware.smack.filter.StanzaFilter的典型用法代码示例。如果您正苦于以下问题:Java StanzaFilter类的具体用法?Java StanzaFilter怎么用?Java StanzaFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StanzaFilter类属于org.jivesoftware.smack.filter包,在下文中一共展示了StanzaFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AgentRoster

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
/**
 * Constructs a new AgentRoster.
 *
 * @param connection an XMPP connection.
 * @throws NotConnectedException 
 */
AgentRoster(XMPPConnection connection, String workgroupJID) throws NotConnectedException {
    this.connection = connection;
    this.workgroupJID = workgroupJID;
    entries = new ArrayList<String>();
    listeners = new ArrayList<AgentRosterListener>();
    presenceMap = new HashMap<String, Map<String, Presence>>();
    // Listen for any roster packets.
    StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class);
    connection.addAsyncStanzaListener(new AgentStatusListener(), rosterFilter);
    // Listen for any presence packets.
    connection.addAsyncStanzaListener(new PresencePacketListener(),
            new StanzaTypeFilter(Presence.class));

    // Send request for roster.
    AgentStatusRequest request = new AgentStatusRequest();
    request.setTo(workgroupJID);
    connection.sendStanza(request);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:AgentRoster.java

示例2: addOneTimeSyncCallback

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) {
    final StanzaListener packetListener = new StanzaListener() {
        @Override
        public void processPacket(Stanza packet) throws NotConnectedException {
            try {
                callback.processPacket(packet);
            } finally {
                removeSyncStanzaListener(this);
            }
        }
    };
    addSyncStanzaListener(packetListener, packetFilter);
    removeCallbacksService.schedule(new Runnable() {
        @Override
        public void run() {
            removeSyncStanzaListener(packetListener);
        }
    }, getPacketReplyTimeout(), TimeUnit.MILLISECONDS);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:AbstractXMPPConnection.java

示例3: changeNickname

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
/**
 * Changes the occupant's nickname to a new nickname within the room. Each room occupant
 * will receive two presence packets. One of type "unavailable" for the old nickname and one
 * indicating availability for the new nickname. The unavailable presence will contain the new
 * nickname and an appropriate status code (namely 303) as extended presence information. The
 * status code 303 indicates that the occupant is changing his/her nickname.
 *
 * @param nickname the new nickname within the room.
 * @throws XMPPErrorException if the new nickname is already in use by another occupant.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
    // Check that we already have joined the room before attempting to change the
    // nickname.
    if (!joined) {
        throw new IllegalStateException("Must be logged into the room to change nickname.");
    }
    // We change the nickname by sending a presence packet where the "to"
    // field is in the form "[email protected]/nickname"
    // We don't have to signal the MUC support again
    Presence joinPresence = new Presence(Presence.Type.available);
    joinPresence.setTo(room + "/" + nickname);

    // Wait for a presence packet back from the server.
    StanzaFilter responseFilter =
        new AndFilter(
            FromMatchesFilter.createFull(room + "/" + nickname),
            new StanzaTypeFilter(Presence.class));
    PacketCollector response = connection.createPacketCollectorAndSend(responseFilter, joinPresence);
    // Wait up to a certain number of seconds for a reply. If there is a negative reply, an
    // exception will be thrown
    response.nextResultOrThrow();

    this.nickname = nickname;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:38,代码来源:MultiUserChat.java

示例4: changeSubject

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
/**
 * Changes the subject within the room. As a default, only users with a role of "moderator"
 * are allowed to change the subject in a room. Although some rooms may be configured to
 * allow a mere participant or even a visitor to change the subject.
 *
 * @param subject the new room's subject to set.
 * @throws XMPPErrorException if someone without appropriate privileges attempts to change the
 *          room subject will throw an error with code 403 (i.e. Forbidden)
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException {
    Message message = createMessage();
    message.setSubject(subject);
    // Wait for an error or confirmation message back from the server.
    StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
        @Override
        public boolean accept(Stanza packet) {
            Message msg = (Message) packet;
            return subject.equals(msg.getSubject());
        }
    });
    PacketCollector response = connection.createPacketCollectorAndSend(responseFilter, message);
    // Wait up to a certain number of seconds for a reply.
    response.nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:MultiUserChat.java

示例5: sendRestDocument

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public ResourceDocument sendRestDocument(XmppURI uri, ResourceDocument document) throws XMPPException, IOException, SmackException {
    AbstractXMPPConnection connection = this.connectionManager.getConnection();

    // create an set IQ stanza to uri
    RestIQ setIQ = new RestIQ(uri, document);
    // send stanza
    connection.sendStanza(setIQ);
    // wait for response
    StanzaFilter filter = new AndFilter(new IQReplyFilter(setIQ, connection));
    PacketCollector collector = connection.createPacketCollector(filter);
    IQ resultIQ = collector.nextResultOrThrow();
    if(resultIQ instanceof RestIQ) {
        // create rest doc
        return ((RestIQ) resultIQ).getResourceDocument();
    } else {
        throw new SmackException("Wrong RestIQ has been passed");
    }
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:20,代码来源:XmppService.java

示例6: getXwadlDocument

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public ResourceTypeDocument getXwadlDocument(XmppURI uri) throws XMPPException, IOException, SmackException {
    AbstractXMPPConnection connection = this.connectionManager.getConnection();
    // create an get IQ stanza to uri
    IQ getIQ = new GetXwadlIQ(uri);

    // send stanza
    connection.sendStanza(getIQ);
    // wait for response
    StanzaFilter filter = new AndFilter(new IQReplyFilter(getIQ, connection));
    PacketCollector collector = connection.createPacketCollector(filter);
    IQ resultIQ = collector.nextResultOrThrow();
    if (resultIQ instanceof XwadlIQ) {
        // create xwadl
        return ((XwadlIQ) resultIQ).getXwadl();
    } else {
        throw new SmackException("Wrong IQ has been passed");
    }
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:20,代码来源:XmppService.java

示例7: initListeners

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
/**
 * Initialize PacketListener for a given {@link org.jivesoftware.smack.XMPPConnection}
 * and a Command prefix
 *
 * @param prefix the command prefix used to filter message
 * @param connection the connection on which PacketListener will be registered
 */
private void initListeners(final String prefix, final XMPPConnection connection){
       StanzaFilter filter = new AndFilter(
			new OrFilter(MessageTypeFilter.GROUPCHAT,MessageTypeFilter.CHAT),
			new StanzaFilter() {
				@Override
				public boolean accept(Stanza stanza) {
					return stanza instanceof Message && ((Message) stanza).getBody().startsWith(prefix);
				}
			}
	);

	XmppMessageListener commandListener = new XmppMessageListener(this,listeners);
	connection.addAsyncStanzaListener(commandListener,filter);
	MultiUserChatManager.getInstanceFor(connection).addInvitationListener(new InvitationListener(this,listeners));
}
 
开发者ID:midoricorp,项目名称:jabbot,代码行数:23,代码来源:XmppBinding.java

示例8: processStanza

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void processStanza(Stanza packet) {
    XMPPConnection conn = getConnection();

    // we don't need this listener anymore
    conn.removeAsyncStanzaListener(this);

    DiscoverItems query = (DiscoverItems) packet;
    List<DiscoverItems.Item> items = query.getItems();
    for (DiscoverItems.Item item : items) {
        DiscoverInfo info = new DiscoverInfo();
        info.setTo(item.getEntityID());

        StanzaFilter filter = new StanzaIdFilter(info.getStanzaId());
        conn.addAsyncStanzaListener(new DiscoverInfoListener(getInstance()), filter);
        sendPacket(info);
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:19,代码来源:DiscoverItemsListener.java

示例9: sendStanzaInternal

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
protected void sendStanzaInternal(Stanza packet) throws NotConnectedException {
    packetWriter.sendStreamElement(packet);
    if (isSmEnabled()) {
        for (StanzaFilter requestAckPredicate : requestAckPredicates) {
            if (requestAckPredicate.accept(packet)) {
                requestSmAcknowledgementInternal();
                break;
            }
        }
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:XMPPTCPConnection.java

示例10: accept

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public boolean accept(Stanza packet) {
    for (StanzaFilter predicate : predicates) {
        if (predicate.accept(packet)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:ShortcutPredicates.java

示例11: createPacketCollectorAndSend

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException {
    StanzaFilter packetFilter = new IQReplyFilter(packet, this);
    // Create the packet collector before sending the packet
    PacketCollector packetCollector = createPacketCollectorAndSend(packetFilter, packet);
    return packetCollector;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:AbstractXMPPConnection.java

示例12: addSyncStanzaListener

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
    if (packetListener == null) {
        throw new NullPointerException("Packet listener is null.");
    }
    ListenerWrapper wrapper = new ListenerWrapper(packetListener, packetFilter);
    synchronized (syncRecvListeners) {
        syncRecvListeners.put(packetListener, wrapper);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:AbstractXMPPConnection.java

示例13: addAsyncStanzaListener

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
    if (packetListener == null) {
        throw new NullPointerException("Packet listener is null.");
    }
    ListenerWrapper wrapper = new ListenerWrapper(packetListener, packetFilter);
    synchronized (asyncRecvListeners) {
        asyncRecvListeners.put(packetListener, wrapper);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:AbstractXMPPConnection.java

示例14: addPacketSendingListener

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
    if (packetListener == null) {
        throw new NullPointerException("Packet listener is null.");
    }
    ListenerWrapper wrapper = new ListenerWrapper(packetListener, packetFilter);
    synchronized (sendListeners) {
        sendListeners.put(packetListener, wrapper);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:AbstractXMPPConnection.java

示例15: addPacketInterceptor

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void addPacketInterceptor(StanzaListener packetInterceptor,
        StanzaFilter packetFilter) {
    if (packetInterceptor == null) {
        throw new NullPointerException("Packet interceptor is null.");
    }
    InterceptorWrapper interceptorWrapper = new InterceptorWrapper(packetInterceptor, packetFilter);
    synchronized (interceptors) {
        interceptors.put(packetInterceptor, interceptorWrapper);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:AbstractXMPPConnection.java


注:本文中的org.jivesoftware.smack.filter.StanzaFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。