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


Java Stanza類代碼示例

本文整理匯總了Java中tigase.jaxmpp.core.client.xmpp.stanzas.Stanza的典型用法代碼示例。如果您正苦於以下問題:Java Stanza類的具體用法?Java Stanza怎麽用?Java Stanza使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Stanza類屬於tigase.jaxmpp.core.client.xmpp.stanzas包,在下文中一共展示了Stanza類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(Stanza responseStanza) throws JaxmppException {
	Element pubsub = responseStanza.getChildrenNS("pubsub", PUBSUB_XMLNS);
	if (pubsub == null)
		pubsub = responseStanza.getChildrenNS("pubsub", PUBSUB_OWNER_XMLNS);
	Element affiliations = getFirstChild(pubsub, "affiliations");
	String node = affiliations.getAttribute("node");

	ArrayList<AffiliationElement> affiliationWrappers = new ArrayList<AffiliationElement>();
	List<Element> afch = affiliations.getChildren();
	if (afch != null)
		for (Element element : afch) {
			affiliationWrappers.add(new AffiliationElement(element));
		}

	onRetrieve((IQ) responseStanza, node, affiliationWrappers);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:18,代碼來源:PubSubModule.java

示例2: onError

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public final void onError(Stanza responseStanza, ErrorCondition errorCondition) throws JaxmppException {
	List<Element> errors = responseStanza.getChildren("error");
	Element error = errors == null || errors.isEmpty() ? null : errors.get(0);
	PubSubErrorCondition pubSubErrorCondition = null;

	List<Element> perrors = error.getChildrenNS("http://jabber.org/protocol/pubsub#errors");
	Element perror = perrors == null || perrors.isEmpty() ? null : perrors.get(0);

	if (perror != null) {
		String c = perror.getName();
		String feature = perror.getAttribute("feature");

		if (feature != null)
			c = c + "_" + feature;

		try {
			pubSubErrorCondition = PubSubErrorCondition.valueOf(c.replace("-", "_"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	onEror((IQ) responseStanza, errorCondition, pubSubErrorCondition);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:26,代碼來源:PubSubAsyncCallback.java

示例3: requestStreamHosts

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
protected void requestStreamHosts(final JaxmppCore jaxmpp, final ConnectionSession session, final JID proxyJid)
		throws JaxmppException {
	Socks5BytestreamsModule socks5Module = jaxmpp.getModule(Socks5BytestreamsModule.class);
	socks5Module.requestStreamhosts(proxyJid, new StreamhostsCallback(socks5Module) {

		@Override
		public void onError(Stanza responseStanza, XMPPException.ErrorCondition error) throws JaxmppException {
			sendStreamHosts(jaxmpp, session, null);
		}

		@Override
		public void onStreamhosts(List<Streamhost> hosts) throws JaxmppException {
			sendStreamHosts(jaxmpp, session, hosts);
		}

		@Override
		public void onTimeout() throws JaxmppException {
			sendStreamHosts(jaxmpp, session, null);
		}

	});
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:23,代碼來源:Socks5BytestreamsConnectionManager.java

示例4: 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

示例5: 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

示例6: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(Stanza responseStanza) throws XMLException {
	this.responseStanza = responseStanza;
	Element query = responseStanza.getChildrenNS("query", INFO_XMLNS);
	List<Element> identities = query.getChildren("identity");
	ArrayList<Identity> idres = new ArrayList<Identity>();
	for (Element id : identities) {
		Identity t = new Identity();
		t.setName(id.getAttribute("name"));
		t.setType(id.getAttribute("type"));
		t.setCategory(id.getAttribute("category"));
		idres.add(t);
	}

	List<Element> features = query.getChildren("feature");
	ArrayList<String> feres = new ArrayList<String>();
	for (Element element : features) {
		String v = element.getAttribute("var");
		if (v != null)
			feres.add(v);
	}

	String n = query.getAttribute("node");
	onInfoReceived(n == null ? requestedNode : n, idres, feres);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:26,代碼來源:DiscoveryModule.java

示例7: processStreamhosts

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
List<Streamhost> processStreamhosts(Stanza iq) throws XMLException {
	Element query = iq.getChildrenNS("query", XMLNS_BS);
	List<Element> el_hosts = query.getChildren("streamhost");

	if (el_hosts == null)
		return null;

	List<Streamhost> hosts = new ArrayList<Streamhost>();

	if (el_hosts != null) {
		StreamhostsEvent event = new StreamhostsEvent(this.context.getSessionObject());
		for (Element el_host : el_hosts) {
			String jid = el_host.getAttribute("jid");
			hosts.add(new Streamhost(jid, el_host.getAttribute("host"), Integer.parseInt(el_host.getAttribute("port"))));
		}
	}

	return hosts;
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:20,代碼來源:Socks5BytestreamsModule.java

示例8: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess( Stanza responseStanza ) throws XMLException {
	final Element query = responseStanza.getChildrenNS( "query", ITEMS_XMLNS );
	List<Element> ritems = query.getChildren( "item" );
	ArrayList<Item> items = new ArrayList<Item>();
	for ( Element i : ritems ) {
		Item to = new Item();
		if ( i.getAttribute( "jid" ) != null ){
			to.setJid( JID.jidInstance( i.getAttribute( "jid" ) ) );
		}
		to.setName( i.getAttribute( "name" ) );
		to.setNode( i.getAttribute( "node" ) );
		if ( i.getAttribute( "type" ) != null ){
			to.setType( MSG_TYPE.valueOf( i.getAttribute( "type" ) ) );
		}
		items.add( to );
	}
	onOfflineMessageListReceived( items );
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:20,代碼來源:FlexibleOfflineMessageRetrieval.java

示例9: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void onSuccess(final Stanza responseStanza) throws JaxmppException {
	this.response = (IQ) responseStanza;
	this.command = responseStanza.getChildrenNS("command", "http://jabber.org/protocol/commands");

	if (this.command != null) {
		String sessionid = this.command.getAttribute("sessionid");
		String node = this.command.getAttribute("node");
		State status = this.command.getAttribute("status") == null ? null
				: State.valueOf(this.command.getAttribute("status"));

		JabberDataElement data = new JabberDataElement(this.command.getChildrenNS("x", "jabber:x:data"));

		onResponseReceived(sessionid, node, status, data);
	}

}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:21,代碼來源:AdHocCommansModule.java

示例10: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(final Stanza stanza) throws XMLException {
	ResultSet<Chat> rs = new ResultSet<Chat>();

	Element rsm = stanza.getChildrenNS("set", "http://jabber.org/protocol/rsm");
	if (rsm != null) {
		rs.process(rsm);
	}

	for (Element it : stanza.getChildrenNS("list", ARCHIVE_XMLNS).getChildren()) {
		if ("chat".equals(it.getName())) {
			Chat chat = new Chat();
			chat.process(it, format);
			rs.getItems().add(chat);
		}
	}
	onCollectionReceived(rs);
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:19,代碼來源:MessageArchivingModule.java

示例11: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(Stanza responseStanza) throws JaxmppException {
	final Element event = responseStanza.getChildrenNS("pubsub", PUBSUB_XMLNS);
	List<Element> tmp = event == null ? null : event.getChildren("items");
	final Element items = tmp == null || tmp.isEmpty() ? null : tmp.get(0);
	final String nodeName = items == null ? null : items.getAttribute("node");

	ArrayList<Item> result = new ArrayList<Item>();

	List<Element> itemElements = items == null ? null : items.getChildren("item");
	if (itemElements != null)
		for (Element item : itemElements) {
			final String itemId = item.getAttribute("id");
			final Element payload = item.getFirstChild();

			Item it = new Item(itemId, payload);
			result.add(it);
		}

	onRetrieve((IQ) responseStanza, nodeName, result);
}
 
開發者ID:liule,項目名稱:tigase-jaxmpp2,代碼行數:22,代碼來源:PubSubModule.java

示例12: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(Stanza responseStanza) throws XMLException {
	Element query = responseStanza.getChildrenNS("query", "http://jabber.org/protocol/disco#info");
	List<Element> identities = query.getChildren("identity");
	ArrayList<Identity> idres = new ArrayList<DiscoInfoModule.Identity>();
	for (Element id : identities) {
		Identity t = new Identity();
		t.setName(id.getAttribute("name"));
		t.setType(id.getAttribute("type"));
		t.setCategory(id.getAttribute("category"));
		idres.add(t);
	}

	List<Element> features = query.getChildren("feature");
	ArrayList<String> feres = new ArrayList<String>();
	for (Element element : features) {
		String v = element.getAttribute("var");
		if (v != null)
			feres.add(v);
	}

	String n = query.getAttribute("node");
	onInfoReceived(n == null ? requestedNode : n, idres, feres);
}
 
開發者ID:liule,項目名稱:tigase-jaxmpp2,代碼行數:25,代碼來源:DiscoInfoModule.java

示例13: 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

示例14: 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

示例15: onSuccess

import tigase.jaxmpp.core.client.xmpp.stanzas.Stanza; //導入依賴的package包/類
@Override
public void onSuccess(final Stanza responseStanza) throws XMLException {
	Element query = responseStanza.getChildrenNS("query", "jabber:iq:version");
	if (query != null) {
		String eName = getFirst(query.getChildren("name"));
		String eVersion = getFirst(query.getChildren("version"));
		String eOs = getFirst(query.getChildren("os"));
		onVersionReceived(eName, eVersion, eOs);
	}
}
 
開發者ID:horsefaced,項目名稱:jaxmpp-android,代碼行數:11,代碼來源:SoftwareVersionModule.java


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