本文整理匯總了Java中tigase.jaxmpp.core.client.xmpp.stanzas.Stanza.canBeConverted方法的典型用法代碼示例。如果您正苦於以下問題:Java Stanza.canBeConverted方法的具體用法?Java Stanza.canBeConverted怎麽用?Java Stanza.canBeConverted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tigase.jaxmpp.core.client.xmpp.stanzas.Stanza
的用法示例。
在下文中一共展示了Stanza.canBeConverted方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onResponse
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
protected void onResponse(final Element response) throws JaxmppException {
synchronized (ioMutex) {
if ("error".equals(response.getName()) && response.getXMLNS() != null
&& response.getXMLNS().equals("http://etherx.jabber.org/streams")) {
onError(response, null);
} else {
StreamPacket p;
if (Stanza.canBeConverted(response)) {
p = Stanza.create(response);
} else {
p = new StreamPacket(response) {
};
}
p.setXmppStream(context.getStreamsManager().getDefaultStream());
fireOnStanzaReceived(p, context.getSessionObject());
}
}
}
示例2: processElement
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
protected void processElement(Element child) throws JaxmppException {
boolean isRfc = isRfc();
if (isRfc && "urn:ietf:params:xml:ns:xmpp-framing".equals(child.getXMLNS())) {
if ("close".equals(child.getName())) {
if (child.getAttribute("see-other-uri") != null) {
// received new version of see-other-host called
// see-other-uri
// designed just for XMPP over WebSocket
String uri = child.getAttribute("see-other-uri");
handleSeeOtherUri(uri);
return;
}
log.finest("received <close/> stanza, so we need to close this connection..");
// stop();
this.onStreamTerminate();
}
if ("open".equals(child.getName())) {
// received <open/> stanza should be ignored
this.onStreamStart(child.getAttributes());
return;
}
}
if (("error".equals(child.getName()) && child.getXMLNS() != null && child.getXMLNS().equals(
"http://etherx.jabber.org/streams"))
|| "stream:error".equals(child.getName())) {
onError(child, null);
} else {
StreamPacket p;
if (Stanza.canBeConverted(child)) {
p = Stanza.create(child);
} else {
p = new StreamPacket(child) {
};
}
p.setXmppStream(context.getStreamsManager().getDefaultStream());
fireOnStanzaReceived(p, context.getSessionObject());
}
}
示例3: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
/**
* Produces {@link Runnable} that must be run to fully process received
* stanza.
*
* @param element
* received stanza
* @return {@linkplain Runnable}
*/
public Runnable process(final Element receivedElement) {
try {
final Element element = Stanza.canBeConverted(receivedElement) ? Stanza.create(receivedElement) : receivedElement;
Runnable result = ResponseManager.getResponseHandler(context, element);
if (result != null)
return result;
if (element.getName().equals("iq") && element.getAttribute("type") != null
&& (element.getAttribute("type").equals("error") || element.getAttribute("type").equals("result")))
return null;
final List<XmppModule> modules = xmppModulesManages.findModules(element);
if (modules == null)
result = new FeatureNotImplementedResponse(element, context);
else {
result = new AbstractStanzaHandler(element, context) {
@Override
protected void process() throws XMLException, XMPPException, JaxmppException {
for (XmppModule module : modules) {
Element e = this.element;
if (module instanceof ExtendableModule) {
e = ((ExtendableModule) module).getExtensionChain().executeAfterReceiveChain(e);
}
if (e != null)
module.process(e);
}
}
};
}
return result;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
示例4: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
/**
* Process received stanza.
*
* @param element
* received stanza
* @return {@linkplain Runnable}
*/
public Runnable process(final Element receivedElement) {
try {
final Element element = Stanza.canBeConverted(receivedElement) ? Stanza.create(receivedElement) : receivedElement;
Runnable result = sessionObject.getResponseHandler(element, writer);
if (result != null)
return result;
if (element.getName().equals("iq") && element.getAttribute("type") != null
&& (element.getAttribute("type").equals("error") || element.getAttribute("type").equals("result")))
return null;
final List<XmppModule> modules = xmppModulesManages.findModules(element);
if (modules == null)
result = new FeatureNotImplementedResponse(element, writer, sessionObject);
else {
result = new AbstractStanzaHandler(element, writer, sessionObject) {
@Override
protected void process() throws XMLException, XMPPException, JaxmppException {
for (XmppModule module : modules) {
module.process(this.element);
}
}
};
}
return result;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
示例5: getResponseHandler
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
/**
* Returns handler for response of sent <code><iq/></code> stanza.
*
* @param element
* reponse <code><iq/></code> stanza.
* @param writer
* Packet writer
* @return Runnable object with handler
* @throws XMLException
*/
public Runnable getResponseHandler(final Element element, Context context) throws JaxmppException {
if (!Stanza.canBeConverted(element))
return null;
final String id = element.getAttribute("id");
if (id == null)
return null;
final Entry entry = this.getHandlers().get(id);
if (entry == null)
return null;
if (!verify(element, entry, context.getSessionObject()))
return null;
this.getHandlers().remove(id);
AbstractStanzaHandler r = new AbstractStanzaHandler(element, context) {
@Override
protected void process() throws JaxmppException {
final String type = this.element.getAttribute("type");
if (type != null && type.equals("result")) {
entry.callback.onSuccess(Stanza.create(this.element));
} else if (type != null && type.equals("error")) {
List<Element> es = this.element.getChildren("error");
final Element error;
if (es != null && es.size() > 0)
error = es.get(0);
else
error = null;
ErrorCondition errorCondition = null;
if (error != null) {
List<Element> conds = error.getChildrenNS(XMPPException.XMLNS);
if (conds != null && conds.size() > 0) {
errorCondition = ErrorCondition.getByElementName(conds.get(0).getName());
}
}
entry.callback.onError(Stanza.create(this.element), errorCondition);
}
}
};
return r;
}
示例6: getResponseHandler
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
/**
* Returns handler for response of sent <code><iq/></code> stanza.
*
* @param element
* reponse <code><iq/></code> stanza.
* @param writer
* Packet writer
* @return Runnable object with handler
* @throws XMLException
*/
public Runnable getResponseHandler(final Element element, PacketWriter writer, SessionObject sessionObject)
throws JaxmppException {
if (!Stanza.canBeConverted(element))
return null;
final String id = element.getAttribute("id");
if (id == null)
return null;
final Entry entry = this.getHandlers().get(id);
if (entry == null)
return null;
if (!verify(element, entry, sessionObject))
return null;
this.getHandlers().remove(id);
AbstractStanzaHandler r = new AbstractStanzaHandler(element, writer, sessionObject) {
@Override
protected void process() throws JaxmppException {
final String type = this.element.getAttribute("type");
if (type != null && type.equals("result")) {
entry.callback.onSuccess(Stanza.create(this.element));
} else if (type != null && type.equals("error")) {
List<Element> es = this.element.getChildren("error");
final Element error;
if (es != null && es.size() > 0)
error = es.get(0);
else
error = null;
ErrorCondition errorCondition = null;
if (error != null) {
List<Element> conds = error.getChildrenNS(XMPPException.XMLNS);
if (conds != null && conds.size() > 0) {
errorCondition = ErrorCondition.getByElementName(conds.get(0).getName());
}
}
entry.callback.onError(Stanza.create(this.element), errorCondition);
}
}
};
return r;
}