本文整理匯總了Java中tigase.jaxmpp.core.client.xmpp.stanzas.Stanza.create方法的典型用法代碼示例。如果您正苦於以下問題:Java Stanza.create方法的具體用法?Java Stanza.create怎麽用?Java Stanza.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tigase.jaxmpp.core.client.xmpp.stanzas.Stanza
的用法示例。
在下文中一共展示了Stanza.create方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: fromJSON
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
@Override
public Object fromJSON(JsonSerializationHelper helper, JavaScriptObject obj) throws JaxmppException {
String type = JsonSerializationHelper.getStringFromObject(obj, "type");
if (!getJsonType().equals(type)) {
return null;
}
JavaScriptObject presences = JsonSerializationHelper.getObjectFromObject(obj, "items");
JsArrayString jids = JsonSerializationHelper.getKeysFromObject(presences);
for (int i=0; i<jids.length(); i++) {
String key = jids.get(i);
JID jid = JID.jidInstance(key);
JavaScriptObject jsPresence = JsonSerializationHelper.getObjectFromObject(presences, key);
Element el = (Element) helper.fromJSON(jsPresence);
Presence presence = (Presence) Stanza.create(el);
update(presence);
}
return this;
}
示例3: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
@Override
public void process(Element element) throws XMPPException, XMLException, JaxmppException {
if ("iq".equals(element.getName())) {
IQ iq = (IQ) Stanza.create(element);
processIq(iq);
}
}
示例4: 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());
}
}
示例5: 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);
}
}
示例6: processReceivedCarbon
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
protected void processReceivedCarbon(final Message message, final Element carb) throws JaxmppException {
final Element forwarded = carb.getChildrenNS("forwarded", XMLNS_SF);
List<Element> c = forwarded.getChildren("message");
for (Element element : c) {
Message encapsulatedMessage = (Message) Stanza.create(element);
JID interlocutorJid = encapsulatedMessage.getFrom();
Chat chat = this.messageModule.process(encapsulatedMessage, interlocutorJid, false);
CarbonReceivedHandler.CarbonReceivedEvent event = new CarbonReceivedHandler.CarbonReceivedEvent(
context.getSessionObject(), CarbonEventType.received, encapsulatedMessage, chat);
fireEvent(event);
}
}
示例7: processSentCarbon
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
protected void processSentCarbon(final Message message, final Element carb) throws JaxmppException {
final Element forwarded = carb.getChildrenNS("forwarded", XMLNS_SF);
List<Element> c = forwarded.getChildren("message");
for (Element element : c) {
Message encapsulatedMessage = (Message) Stanza.create(element);
JID interlocutorJid = encapsulatedMessage.getTo();
Chat chat = this.messageModule.process(encapsulatedMessage, interlocutorJid, false);
CarbonReceivedHandler.CarbonReceivedEvent event = new CarbonReceivedHandler.CarbonReceivedEvent(
context.getSessionObject(), CarbonEventType.sent, encapsulatedMessage, chat);
fireEvent(event);
}
}
示例8: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
@Override
public void process(Element $element) throws JaxmppException {
final Stanza stanza = Stanza.create($element);
final StanzaType type = stanza.getType();
if (stanza instanceof IQ && type == StanzaType.set)
processSet((IQ) stanza);
else if (stanza instanceof IQ && type == StanzaType.get)
processGet((IQ) stanza);
else {
log.log(Level.WARNING, "Unhandled stanza " + $element.getName() + ", type=" + $element.getAttribute("type")
+ ", id=" + $element.getAttribute("id"));
throw new XMPPException(ErrorCondition.bad_request);
}
}
示例9: 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);
}
}
示例10: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void process(Element element) throws JaxmppException {
final T stanza = (T) Stanza.create(element);
process(stanza);
}
示例11: process
import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入方法依賴的package包/類
@Override
public void process(Element element) throws XMPPException, XMLException, JaxmppException {
final IQ iq = element instanceof Stanza ? (IQ) element : (IQ) Stanza.create(element);
process(iq);
}