package com.imofan.android.pns.old;

import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Packet;

/**
 * Created with IntelliJ IDEA.
 * User: Rex
 * Date: 12-8-20
 * Time: 上午9:56
 * To change this template use File | Settings | File Templates.
 */
public class PingPacketListener implements PacketListener {
    private final static String LOG_TAG = "Mofang_PNS_PingPacketListener";
    private XMPPConnection connection;

    public PingPacketListener(XMPPConnection connection) {
        this.connection = connection;
    }

    public void processPacket(Packet packet) {
        if(packet == null) {
            return;
        }

        Pong pong = new Pong();
        String from = packet.getFrom();
        String to = packet.getTo();

        pong.setFrom(to);
        pong.setTo(from);

        this.connection.sendPacket(pong);
    }
}
