1 /** 2 * Copyright 2012 Florian Schmaus 3 * 4 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.jivesoftware.smackx.ping.packet; 18 19 import org.jivesoftware.smack.packet.IQ; 20 21 public class Pong extends IQ { 22 23 /** 24 * Composes a Pong packet from a received ping packet. This basically swaps 25 * the 'from' and 'to' attributes. And sets the IQ type to result. 26 * 27 * @param ping 28 */ 29 public Pong(Ping ping) { 30 setType(IQ.Type.RESULT); 31 setFrom(ping.getTo()); 32 setTo(ping.getFrom()); 33 setPacketID(ping.getPacketID()); 34 } 35 36 /* 37 * Returns the child element of the Pong reply, which is non-existent. This 38 * is why we return 'null' here. See e.g. Example 11 from 39 * http://xmpp.org/extensions/xep-0199.html#e2e 40 */ 41 public String getChildElementXML() { 42 return null; 43 } 44 45 } 46