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


Java Connection.addPacketListener方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.Connection.addPacketListener方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.addPacketListener方法的具体用法?Java Connection.addPacketListener怎么用?Java Connection.addPacketListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.Connection的用法示例。


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

示例1: AgentRoster

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Constructs a new AgentRoster.
 *
 * @param connection an XMPP connection.
 */
AgentRoster(Connection connection, String workgroupJID) {
    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.
    PacketFilter rosterFilter = new PacketTypeFilter(AgentStatusRequest.class);
    connection.addPacketListener(new AgentStatusListener(), rosterFilter);
    // Listen for any presence packets.
    connection.addPacketListener(new PresencePacketListener(),
            new PacketTypeFilter(Presence.class));

    // Send request for roster.
    AgentStatusRequest request = new AgentStatusRequest();
    request.setTo(workgroupJID);
    connection.sendPacket(request);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:24,代码来源:AgentRoster.java

示例2: DeliveryReceiptManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
private DeliveryReceiptManager(Connection connection) {
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
    sdm.addFeature(DeliveryReceipt.NAMESPACE);
    this.connection = connection;
    instances.put(connection, this);

    // register listener for delivery receipts and requests
    connection.addPacketListener(this, new PacketExtensionFilter(DeliveryReceipt.NAMESPACE));
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:10,代码来源:DeliveryReceiptManager.java

示例3: PingManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
private PingManager(final Connection connection) {
    this.connection = connection;
    instances.put(connection, this);

    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
    sdm.addFeature(NAMESPACE);

    PacketFilter pingPacketFilter = new PacketTypeFilter(Ping.class);
    connection.addPacketListener(new PacketListener() {
        /**
         * Sends a Pong for every Ping
         */
        public void processPacket(Packet packet) {
            if (pingMinDelta > 0) {
                // Ping flood protection enabled
                long currentMillies = System.currentTimeMillis();
                long delta = currentMillies - lastPingStamp;
                lastPingStamp = currentMillies;
                if (delta < pingMinDelta) {
                    return;
                }
            }
            Pong pong = new Pong((Ping)packet);
            connection.sendPacket(pong);
        }
    }
    , pingPacketFilter);
    connection.addConnectionListener(new ConnectionListener() {

        @Override
        public void connectionClosed() {
            maybeStopPingServerTask();
        }

        @Override
        public void connectionClosedOnError(Exception arg0) {
            maybeStopPingServerTask();
        }

        @Override
        public void reconnectionSuccessful() {
            maybeSchedulePingServerTask();
        }

        @Override
        public void reconnectingIn(int seconds) {
        }

        @Override
        public void reconnectionFailed(Exception e) {
        }
    });
    maybeSchedulePingServerTask();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:55,代码来源:PingManager.java


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