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


C# IQ.isRequest方法代码示例

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


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

示例1: processIQ


//.........这里部分代码省略.........
	 * {@link #handleIQSet()}, {@link #handleIQResult(IQ)},
	 * {@link #handleIQError(IQ)} {@link #handleDiscoInfo(IQ)} and/or
	 * {@link #handleDiscoItems(IQ)}
	 * 
	 * @param iq
	 *            The IQ stanza that was received by this component.
	 */
		private sealed void processIQ(IQ iq)
		{
			log.Debug("(serving component '{}') Processing IQ (packetId {}): {}",
			      new Object[] {getName(), iq.getID(), iq.toXML() });

			IQ response = null;
			Type type = iq.getType();
			try {
				switch (type) {

					case get: // intended fall-through
					case set:
						// cache the id, to prevent the extending implementation from
						// modifying it.
						String requestID = iq.getID();
						response = processIQRequest(iq);
						// validate the response IQ stanza.
						if (response == null) {
							// A request (IQ type 'get' or 'set') MUST be responded to.
							// If no response was generated, create an 'error' type
							// response.
							if (enforceIQResult) {
								response = IQ.createResultIQ(iq);
								response.setError(Condition.feature_not_implemented);
							}
						} else {
							// responses MUST be of type 'result' or 'error'. Everything
							// else is invalid.
							if (!response.isResponse()) {
								throw new IllegalStateException("Responses to IQ "
								                        + "of type <tt>get</tt> or <tt>set</tt> can "
								                        + "only be IQ stanza's of type <tt>error</tt> "
								                        + "or <tt>result</tt>. The response to this "
								                        + "packet was incorrect: " + iq.toXML()
								                        + ". The response was: " + response.toXML());
							}
							// responses must have the same packet ID as the request
							if (!requestID.equals(response.getID())) {
								throw new IllegalStateException("The response to "
								                        + "an request IQ must have the same packet "
								                        + "ID. If this was done intentionally, "
								                        + "#send(Packet) should have been used "
								                        + "instead. The response to this packet "
								                        + "was incorrect: " + iq.toXML()
								                        + ". The response was: " + response.toXML());
							}
							log.debug("(serving component '{}') Responding to IQ (packetId {}) with: {}", new Object[] { getName(), iq.getID(), response.toXML() }); 
						}
						break;

					case result:
						if (servesLocalUsersOnly() && !sentByLocalEntity(iq)) {
							log.info("(serving component '{}') Dropping IQ "
							 + "stanza sent by a user from another domain: {}",
							 getName(), iq.getFrom());
							log.debug("(serving component '{}') Dropping IQ "
							  + "stanza sent by a user from another domain: {}",
							  getName(), iq.toXML());
							return;
						}
						handleIQResult(iq);
						break;

					case error:
						if (servesLocalUsersOnly() && !sentByLocalEntity(iq)) {
							log.info("(serving component '{}') Dropping IQ "
							 + "stanza sent by a user from another domain: {}",
							 getName(), iq.getFrom());
							log.debug("(serving component '{}') Dropping IQ "
							  + "stanza sent by a user from another domain: {}",
							  getName(), iq.toXML());
							return;
						}
						handleIQError(iq);
						break;
				}
			} catch (Exception ex) {
				log.warn("(serving component '" + getName()
				     + "') Unexpected exception while processing IQ stanza: "
				     + iq.toXML(), ex);
				if (iq.isRequest()) {
					// if the received IQ stanza was a 'get' or 'set' request,
					// return an error, as some kind of response MUST be sent back
					// to those stanzas.
					response = IQ.createResultIQ(iq);
					response.setError(Condition.internal_server_error);
				}
			}
			// send the response, if there's any.
			if (response != null) {
				send(response);
			}
		}
开发者ID:kashifsoofi,项目名称:Openfire.Net,代码行数:101,代码来源:AbstractComponent.cs


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