當前位置: 首頁>>代碼示例>>Java>>正文


Java Stanza.create方法代碼示例

本文整理匯總了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());
		}
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:19,代碼來源:SocketConnector.java

示例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;
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:21,代碼來源:GWTPresenceStore.java

示例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);
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:8,代碼來源:JingleModule.java

示例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());
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:40,代碼來源:AbstractWebSocketConnector.java

示例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);
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:45,代碼來源:Processor.java

示例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);
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:15,代碼來源:MessageCarbonsModule.java

示例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);
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:16,代碼來源:MessageCarbonsModule.java

示例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);
	}
}
 
開發者ID:liule,項目名稱:tigase-jaxmpp2,代碼行數:16,代碼來源:AbstractIQModule.java

示例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);
	}
}
 
開發者ID:liule,項目名稱:tigase-jaxmpp2,代碼行數:40,代碼來源:Processor.java

示例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);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:7,代碼來源:AbstractStanzaModule.java

示例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);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:6,代碼來源:Socks5BytestreamsModule.java


注:本文中的tigase.jaxmpp.core.client.xmpp.stanzas.Stanza.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。