use of org.xmpp.jnodes.smack.TrackerEntry in project Openfire by igniterealtime.
the class JingleNodesComponent method handleIQGet.
@Override
protected IQ handleIQGet(IQ iq) throws Exception {
final IQ reply = IQ.createResultIQ(iq);
final Element element = iq.getChildElement();
final String namespace = element.getNamespaceURI();
if (JingleChannelIQ.NAME.equals(element.getName()) && JingleChannelIQ.NAMESPACE.equals(namespace) && UDP.equals(element.attributeValue(PROTOCOL))) {
final Element childElement = iq.getChildElement().createCopy();
final RelayChannel channel = plugin.createRelayChannel();
if (channel != null) {
childElement.addAttribute(HOST, plugin.getPublicIP());
childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA()));
childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB()));
reply.setChildElement(childElement);
Log.debug("Created relay channel {}:{}, {}:{}, {}:{}", new Object[] { HOST, plugin.getPublicIP(), LOCAL_PORT, Integer.toString(channel.getPortA()), REMOTE_PORT, Integer.toString(channel.getPortB()) });
} else {
reply.setError(PacketError.Condition.internal_server_error);
}
return reply;
} else if (JingleTrackerIQ.NAME.equals(element.getName()) && JingleTrackerIQ.NAMESPACE.equals(namespace)) {
final List<TrackerEntry> entries = new ArrayList<TrackerEntry>();
entries.add(new TrackerEntry(TrackerEntry.Type.relay, TrackerEntry.Policy._roster, plugin.getServiceName() + "." + getDomain(), UDP));
final String elements = getChildElementXML(entries);
final Element e = DocumentHelper.parseText(elements).getRootElement();
reply.setChildElement(e);
return reply;
}
// feature not implemented.
return null;
}
use of org.xmpp.jnodes.smack.TrackerEntry in project Openfire by igniterealtime.
the class JingleNodesComponent method getChildElementXML.
public String getChildElementXML(final List<TrackerEntry> entries) {
final StringBuilder str = new StringBuilder();
str.append("<").append(JingleTrackerIQ.NAME).append(" xmlns='").append(JingleTrackerIQ.NAMESPACE).append("'>");
for (final TrackerEntry entry : entries) {
str.append("<").append(entry.getType().toString());
str.append(" policy='").append(entry.getPolicy().toString()).append("'");
str.append(" address='").append(entry.getJid()).append("'");
str.append(" protocol='").append(entry.getProtocol()).append("'");
if (entry.isVerified()) {
str.append(" verified='").append(entry.isVerified()).append("'");
}
str.append("/>");
}
str.append("</").append(JingleTrackerIQ.NAME).append(">");
return str.toString();
}
Aggregations