|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.ex_337.gradient.util.XMPPUtils
Utility class designed to work with SMACK XMPP API.
| Field Summary | |
static org.jivesoftware.smack.filter.PacketFilter |
ALL_PACKETS
Accepts all packets except ERROR and RESULT IQ packets. |
| Constructor Summary | |
XMPPUtils()
|
|
| Method Summary | |
static String |
generateThreadID()
Generates a reasonably unique String for use as a thread ID. |
static DirectivePacketExtension |
getDirectiveExtension(org.jivesoftware.smack.packet.Packet packet)
Returns the directive set extension from a packet, if it exists. |
static IQ |
getIQResponse(org.jivesoftware.smack.XMPPConnection xmppConnection,
IQ request,
String remoteJID,
long timeout)
This allows you to treat IQ a bit like RPC. |
static Element |
getResponseElement(org.jivesoftware.smack.XMPPConnection xmppConnection,
Element element,
IQ.Type type,
String JID,
long timeout)
This allows you to treat IQ as if it were RPC, with the element being the call and the response being the response. |
static TargetPathPacketExtension |
getTargetPathExtension(org.jivesoftware.smack.packet.Packet packet)
Returns the target path extension for a packet, if it exists. |
static boolean |
hasDirectiveExtension(org.jivesoftware.smack.packet.Packet packet)
Checks for the presence of a directive set extension on the given packet. |
static boolean |
hasTargetPathExtension(org.jivesoftware.smack.packet.Packet packet)
Checks for the presence of a target path extension on the given packet |
static boolean |
isSubscribedTo(org.jivesoftware.smack.XMPPConnection xmppConnection,
String remoteJID)
|
static void |
logConnectionEvents(org.jivesoftware.smack.XMPPConnection xmppConnection)
Adds a connectionListener to the given XMPPConnection that logs all connection events to the default Logger, including stack traces on any events triggered by an Exception. |
static void |
logEverything(org.jivesoftware.smack.XMPPConnection xmppConnection)
Adds a connectionListener to the given XMPPConnection that logs all connection events to System.out, including stack traces on any events triggered by an Exception. |
static void |
logIncomingPackets(org.jivesoftware.smack.XMPPConnection xmppConnection)
Logs ALL incoming packets for the given XMPPConnection to the default Logger. |
static void |
logOutgoingPackets(org.jivesoftware.smack.XMPPConnection xmppConnection)
Logs ALL outgoing packets for the given XMPPConnection to the default Logger. |
static Element |
newDocResponseElement()
Creates a blank document response element for use with a DocResponseIQ. |
static void |
prepareEnvironment()
Registers all current Gradient PacketExtensionProviderS and IQProviders with the ProviderManager. |
static void |
printPacket(org.jivesoftware.smack.packet.Packet p)
Utility method for debugging. |
static void |
sendErrorResponse(org.jivesoftware.smack.XMPPConnection xmppConnection,
IQ original,
int code,
String message)
Sends an IQ ERROR response to an IQ. |
static void |
sendReplyPacket(org.jivesoftware.smack.XMPPConnection xmppConnection,
org.jivesoftware.smack.packet.Packet original,
org.jivesoftware.smack.packet.Packet response,
boolean copyID)
Sends the response after setting the from and to fields as the inverse of the original. |
static void |
setReply(org.jivesoftware.smack.packet.Packet original,
org.jivesoftware.smack.packet.Packet response,
boolean copyId)
Sets the correct details on a response packet, optionally copying the ID too. |
static String |
toString(org.jivesoftware.smack.packet.Packet p)
Returns a string representation of a packet. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final org.jivesoftware.smack.filter.PacketFilter ALL_PACKETS
| Constructor Detail |
public XMPPUtils()
| Method Detail |
public static boolean hasDirectiveExtension(org.jivesoftware.smack.packet.Packet packet)
packet - the packet to test
public static DirectivePacketExtension getDirectiveExtension(org.jivesoftware.smack.packet.Packet packet)
packet - the packet enclosing the extension.
ClassCastException - if the DirectivePacketExtensionProvider hasn't been registered.public static boolean hasTargetPathExtension(org.jivesoftware.smack.packet.Packet packet)
packet - the packet to test
public static TargetPathPacketExtension getTargetPathExtension(org.jivesoftware.smack.packet.Packet packet)
packet - the packet enclosing the extension.
ClassCastException - if the TargetPathPacketExtensionProvider hasn't been registered.public static void printPacket(org.jivesoftware.smack.packet.Packet p)
p - the packet to print.public static String toString(org.jivesoftware.smack.packet.Packet p)
p - the packet
public static void logEverything(org.jivesoftware.smack.XMPPConnection xmppConnection)
xmppConnection - the connection for which to log connection events.public static void logConnectionEvents(org.jivesoftware.smack.XMPPConnection xmppConnection)
xmppConnection - the connection for which to log connection events.public static void logIncomingPackets(org.jivesoftware.smack.XMPPConnection xmppConnection)
xmppConnection - the connection for which to log incoming packets.public static void logOutgoingPackets(org.jivesoftware.smack.XMPPConnection xmppConnection)
xmppConnection - the connection for which to log outgoing packets.
public static IQ getIQResponse(org.jivesoftware.smack.XMPPConnection xmppConnection,
IQ request,
String remoteJID,
long timeout)
xmppConnection - the connection to send the IQ onrequest - the request IQ.timeout - the time to wait for a response. use -1 to have no timeout.remoteJID - the Jabber ID to send the IQ to.
public static Element getResponseElement(org.jivesoftware.smack.XMPPConnection xmppConnection,
Element element,
IQ.Type type,
String JID,
long timeout)
xmppConnection - the connection to send the IQ onelement - the element to sendtimeout - the time to wait for a response. use -1 to have no timeout.type - the IQ type (GET or SET) to use when sending the element.JID - the Jabber ID to send the element to.
public static void setReply(org.jivesoftware.smack.packet.Packet original,
org.jivesoftware.smack.packet.Packet response,
boolean copyId)
original - the original packetresponse - the response packetcopyId - if true, copy the packet ID.
public static void sendReplyPacket(org.jivesoftware.smack.XMPPConnection xmppConnection,
org.jivesoftware.smack.packet.Packet original,
org.jivesoftware.smack.packet.Packet response,
boolean copyID)
original - the original incoming packetresponse - the outbound packet to send.copyID - if true, copies the ID from the original to the response. Should only be used for IQs.xmppConnection - the connection with which to send the reply packet.
public static void sendErrorResponse(org.jivesoftware.smack.XMPPConnection xmppConnection,
IQ original,
int code,
String message)
xmppConnection - the connection to use.original - the original IQ to reply to.code - the error code.message - the error message.
public static boolean isSubscribedTo(org.jivesoftware.smack.XMPPConnection xmppConnection,
String remoteJID)
xmppConnection - the connectionremoteJID - the XMPP JID of the entity.
public static void prepareEnvironment()
public static final String generateThreadID()
public static Element newDocResponseElement()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||