• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StanzaFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: sendStanzaWithResponseCallback

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
                StanzaListener callback, ExceptionCallback exceptionCallback)
                throws NotConnectedException {
    sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
                    getPacketReplyTimeout());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:AbstractXMPPConnection.java


示例17: sendIqWithResponseCallback

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
@Override
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
                final ExceptionCallback exceptionCallback, long timeout)
                throws NotConnectedException {
    StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
    sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:AbstractXMPPConnection.java


示例18: newWith

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
public static NoResponseException newWith(XMPPConnection connection, StanzaFilter filter) {
    final long replyTimeout = connection.getPacketReplyTimeout();
    final StringBuilder sb = new StringBuilder(256);
    sb.append("No response received within reply timeout. Timeout was "
                    + replyTimeout + "ms (~"
                    + replyTimeout / 1000 + "s). Used filter: ");
    if (filter != null) {
        sb.append(filter.toString());
    }
    else {
        sb.append("No filter used or filter was 'null'");
    }
    sb.append('.');
    return new NoResponseException(sb.toString(), filter);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:16,代码来源:SmackException.java


示例19: isAvailable

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
/**
 * Returns true if the workgroup is available for receiving new requests. The workgroup will be
 * available only when agents are available for this workgroup.
 *
 * @return true if the workgroup is available for receiving new requests.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException {
    Presence directedPresence = new Presence(Presence.Type.available);
    directedPresence.setTo(workgroupJID);
    StanzaFilter typeFilter = new StanzaTypeFilter(Presence.class);
    StanzaFilter fromFilter = FromMatchesFilter.create(workgroupJID);
    PacketCollector collector = connection.createPacketCollectorAndSend(new AndFilter(fromFilter,
            typeFilter), directedPresence);

    Presence response = (Presence)collector.nextResultOrThrow();
    return Presence.Type.available == response.getType();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:Workgroup.java


示例20: sendMessage

import org.jivesoftware.smack.filter.StanzaFilter; //导入依赖的package包/类
void sendMessage(Chat chat, Message message) throws NotConnectedException {
    for(Map.Entry<MessageListener, StanzaFilter> interceptor : interceptors.entrySet()) {
        StanzaFilter filter = interceptor.getValue();
        if(filter != null && filter.accept(message)) {
            interceptor.getKey().processMessage(message);
        }
    }
    // Ensure that messages being sent have a proper FROM value
    if (message.getFrom() == null) {
        message.setFrom(connection().getUser());
    }
    connection().sendStanza(message);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:ChatManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnitGraph类代码示例发布时间:2022-05-21
下一篇:
Java AbstractComponentState类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap