当前位置: 首页>>代码示例>>C#>>正文


C# IQ.getChildElement方法代码示例

本文整理汇总了C#中IQ.getChildElement方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.getChildElement方法的具体用法?C# IQ.getChildElement怎么用?C# IQ.getChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQ的用法示例。


在下文中一共展示了IQ.getChildElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: processIQRequest

		/**
	 * Processes IQ request stanzas (IQ stanzas of type <tt>get</tt> or
	 * <tt>set</tt>. This method will, in order:
	 * <p/>
	 * <ol>
	 * <li>check if the stanza is a valid request stanza. If not, an IQ stanza
	 * of type <tt>error</tt>, condition 'bad-request' is returned;</li>
	 * <li>process Service Discovery requests by calling
	 * {@link #handleDiscoInfo(IQ)} and {@link #handleDiscoItems(IQ)} where
	 * appropriate;</li>
	 * <li>call the abstract methods {@link #handleIQGet()} or
	 * {@link #handleIQSet()} if the above actions did not apply to the request.
	 * </li>
	 * </ol>
	 * <p/>
	 * Note that if this method returns <tt>null</tt>, an IQ stanza of type
	 * <tt>error</tt>, condition <tt>feature-not-implemented</tt> will be
	 * returned to the sender of the original request. This behavior can be
	 * disabled by setting the <tt>enforceIQResult</tt> argument in the
	 * constructor to <tt>false</tt>.
	 * <p/>
	 * Note that if this method throws an Exception, an IQ stanza of type
	 * <tt>error</tt>, condition 'internal-server-error' will be returned to the
	 * sender of the original request.
	 * <p/>
	 * Note that if you want to add or adjust functionality, you should
	 * <strong>not</strong> override this method. Instead, you probably want to
	 * override any of these methods: {@link #handleIQGet()},
	 * {@link #handleIQSet()}, {@link #handleDiscoInfo(IQ)} and/or
	 * {@link #handleDiscoItems(IQ)}
	 * 
	 * @param iq
	 *            The IQ request stanza.
	 * @return Response to the request, or null to indicate a
	 *         'feature-not-implemented' error.
	 */
		private sealed IQ processIQRequest(IQ iq)
		{
			log.Debug("(serving component '{}') Processing IQ "
			      + "request (packetId {}).", getName(), iq.getID());

			// IQ get (and set) stanza's MUST be replied to.
			XElement childElement = iq.getChildElement();
			string @namespace = null;
			if (childElement != null) {
				@namespace = childElement.getNamespaceURI();
			}
			if (@namespace == null) {
				log.Debug("(serving component '{}') Invalid XMPP "
				      + "- no child element or namespace in IQ "
				      + "request (packetId {})", getName(), iq.getID());
				// this isn't valid XMPP.
				IQ response = IQ.createResultIQ(iq);
				response.setError(Condition.bad_request);
				return response;
			}
			// check if this is a component for local users only.
			if (servesLocalUsersOnly() && !sentByLocalEntity(iq)) {
				log.Info("(serving component '{}') Returning "
				     + "'not-authorized' IQ error to a user from "
				     + "another domain: {}", getName(), iq.getFrom());
				log.Debug("(serving component '{}') Returning "
				      + "'not-authorized' IQ error to a user from "
				      + "another domain: {}", getName(), iq.toXML());
				IQ error = IQ.createResultIQ(iq);
				error.setError(Condition.not_authorized);
				return error;
			}
			Type type = iq.getType();
			if (type == Type.get) {
				if (NAMESPACE_DISCO_INFO.equals(@namespace)) {
					log.Trace("(serving component '{}') "
					      + "Calling #handleDiscoInfo() (packetId {}).",
					      getName(), iq.getID());
					return handleDiscoInfo(iq);
				} else if (NAMESPACE_DISCO_ITEMS.equals(@namespace)) {
					log.Trace("(serving component '{}') "
					      + "Calling #handleDiscoItems() (packetId {}).",
					      getName(), iq.getID());
					return handleDiscoItems(iq);
				} else if (NAMESPACE_XMPP_PING.equals(@namespace)) {
					log.Trace("(serving component '{}') "
					      + "Calling #handlePing() (packetId {}).", getName(), iq
					      .getID());
					return handlePing(iq);
				} else if (NAMESPACE_LAST_ACTIVITY.equals(@namespace)) {
					log.Trace("(serving component '{}') "
					      + "Calling #handleLastActivity() (packetId {}).", getName(), iq
					      .getID());
					return handleLastActivity(iq);
				} else if (NAMESPACE_ENTITY_TIME.equals(@namespace)) {
					log.Trace("(serving component '{}') "
					      + "Calling #handleEntityTime() (packetId {}).", getName(), iq
					      .getID());
					return handleEntityTime(iq);
				} else {
					return handleIQGet(iq);
				}
			}
			if (type == Type.set) {
//.........这里部分代码省略.........
开发者ID:kashifsoofi,项目名称:Openfire.Net,代码行数:101,代码来源:AbstractComponent.cs


注:本文中的IQ.getChildElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。