本文整理汇总了Java中org.xmpp.packet.IQ.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.xmpp.packet.IQ包,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processPacket
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
if (!(p instanceof IQ)) {
return;
}
final IQ packet = (IQ) p;
if (packet.getType().equals(IQ.Type.error) || packet.getType().equals(IQ.Type.result)) {
return;
}
// Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
// replied to.
final IQ replyPacket = handleIQRequest(packet);
try {
componentManager.sendPacket(this, replyPacket);
} catch (ComponentException e) {
Log.error(e.getMessage(), e);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:SearchPlugin.java
示例2: handleDiscoInfo
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Creates a response specific to the search plugin to Disco#Info requests.
*
* @param iq
* The IQ stanza that contains the request.
* @return An IQ stanza, formulated as an answer to the received request.
*/
private static IQ handleDiscoInfo(IQ iq) {
if (iq == null) {
throw new IllegalArgumentException("Argument 'iq' cannot be null.");
}
if (!iq.getChildElement().getNamespaceURI().equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO) || iq.getType() != Type.get) {
throw new IllegalArgumentException("This is not a valid disco#info request.");
}
final IQ replyPacket = IQ.createResultIQ(iq);
final Element responseElement = replyPacket.setChildElement("query", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("identity").addAttribute("category", "directory").addAttribute("type", "user")
.addAttribute("name", "User Search");
responseElement.addElement("feature").addAttribute("var", NAMESPACE_JABBER_IQ_SEARCH);
responseElement.addElement("feature").addAttribute("var", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("feature").addAttribute("var", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT);
return replyPacket;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:SearchPlugin.java
示例3: processPacket
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
if (!(p instanceof IQ)) {
return;
}
final IQ packet = (IQ) p;
if (packet.getType().equals(IQ.Type.error)
|| packet.getType().equals(IQ.Type.result)) {
return;
}
// Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
// replied to.
final IQ replyPacket = handleIQRequest(packet);
try {
componentManager.sendPacket(this, replyPacket);
} catch (ComponentException e) {
Log.error(e.getMessage(), e);
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:SearchPlugin.java
示例4: processPacket
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
if (!(p instanceof IQ)) {
return;
}
final IQ packet = (IQ) p;
if (packet.getType().equals(IQ.Type.error) || packet.getType().equals(IQ.Type.result)) {
return;
}
// Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
// replied to.
final IQ replyPacket = handleIQRequest(packet);
try {
componentManager.sendPacket(this, replyPacket);
} catch (ComponentException e) {
Log.error(e.getMessage(), e);
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:SearchPlugin.java
示例5: handleDiscoInfo
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Creates a response specific to the search plugin to Disco#Info requests.
*
* @param iq
* The IQ stanza that contains the request.
* @return An IQ stanza, formulated as an answer to the received request.
*/
private static IQ handleDiscoInfo(IQ iq) {
if (iq == null) {
throw new IllegalArgumentException("Argument 'iq' cannot be null.");
}
if (!iq.getChildElement().getNamespaceURI().equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO) || iq.getType() != Type.get) {
throw new IllegalArgumentException("This is not a valid disco#info request.");
}
final IQ replyPacket = IQ.createResultIQ(iq);
final Element responseElement = replyPacket.setChildElement("query", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("identity").addAttribute("category", "directory").addAttribute("type", "user")
.addAttribute("name", "User Search");
responseElement.addElement("feature").addAttribute("var", NAMESPACE_JABBER_IQ_SEARCH);
responseElement.addElement("feature").addAttribute("var", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("feature").addAttribute("var", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT);
return replyPacket;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:28,代码来源:SearchPlugin.java
示例6: consumesOnDifferentThreadTest
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* The actual work being done by the component (the consumer) should be done
* by a different thread than the thread that feeds the input (the
* producer).
*
* This test uses an AbstractComponent implementation that reports the
* thread name that was used during processing. This name is compared with
* the name of the thread that feeds the component the request packet (the
* producer) to verify that the producer and consumer threads are indeed
* different.
*/
@Test
public void consumesOnDifferentThreadTest() throws Exception {
// setup
final String producerThreadName = Thread.currentThread().getName();
final IQ request = new IQ(Type.get);
request.setChildElement(
SlowRespondingThreadNameComponent.ELEMENTNAME_THREADNAME,
SlowRespondingThreadNameComponent.DEBUG_NAMESPACE);
// do magic
debugComp.processPacket(request);
final IQ response = (IQ) debugComp.getSentPacket();
// verify
final Element elem = response.getChildElement();
final String consumerThreadName = elem.getText();
assertFalse(consumerThreadName.equals(producerThreadName));
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:30,代码来源:AbstractComponentIsConsumerTest.java
示例7: consumesAsynchronouslyTest
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* The producer thread should be released as soon as it delivers work to the
* consumer, regardless of how long the consumer takes to process a packet.
*
* This test uses an AbstractComponent implementation that takes a
* significant time to process a packet. The test verifies that the producer
* thread finishes work before the consumer threads finish. This verifies
* that the workload has been properly offloaded by the producer thread.
*/
@Test
public void consumesAsynchronouslyTest() throws Exception {
// setup
final IQ request = new IQ(Type.get);
request.setChildElement(
SlowRespondingThreadNameComponent.ELEMENTNAME_SLOWRESPONSE,
SlowRespondingThreadNameComponent.DEBUG_NAMESPACE);
// do magic
final long start = System.currentTimeMillis();
debugComp.processPacket(request);
final long end = System.currentTimeMillis();
// verify
final long elapsed = end - start;
assertTrue(elapsed < 4000);
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentIsConsumerTest.java
示例8: testXmppPing
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* This test verifies that the abstract component responds to XMPP Ping
* requests correctly.
*
* @see <a
* href="http://www.igniterealtime.org/issues/browse/TINDER-20">Tinder bugtracker: TINDER-20</a>
*/
@Test
public void testXmppPing() throws Exception {
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
component.initialize(new JID("sub.domain"), null);
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping",
AbstractComponent.NAMESPACE_XMPP_PING);
pingRequest.setFrom("from.address");
pingRequest.setTo(component.jid);
// do magic
component.start();
component.processPacket(pingRequest);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertEquals(Type.result, result.getType());
assertEquals(pingRequest.getID(), result.getID());
assertEquals(pingRequest.getFrom(), result.getTo());
assertEquals(pingRequest.getTo(), result.getFrom());
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:32,代码来源:AbstractComponentTest.java
示例9: testIsRestartable
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Every component should be functional after it has been shutdown and
* restarted.
*
* This test creates a component, starts, stops and restarts it, and
* verifies that it then responds to XMPP Ping requests.
*
* @see <a
* href="http://www.igniterealtime.org/issues/browse/TINDER-31">Tinder bugtracker: TINDER-31</a>
*/
@Test
public void testIsRestartable() throws Exception {
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
component.initialize(new JID("sub.domain"), null);
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping",
AbstractComponent.NAMESPACE_XMPP_PING);
pingRequest.setFrom("from.address");
pingRequest.setTo(component.jid);
// do magic
component.start();
component.shutdown();
component.start();
component.processPacket(pingRequest);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertEquals(Type.result, result.getType());
assertEquals(pingRequest.getID(), result.getID());
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:35,代码来源:AbstractComponentTest.java
示例10: testLastActivity
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* This test verifies that the abstract component responds to XMPP Last Activity
* requests correctly.
*
* @see <a
* href="http://www.igniterealtime.org/issues/browse/TINDER-38">Tinder bugtracker: TINDER-38</a>
*/
@Test
public void testLastActivity() throws Exception {
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
component.initialize(new JID("sub.domain"), null);
final IQ request = new IQ(Type.get);
request.setChildElement("ping",
AbstractComponent.NAMESPACE_LAST_ACTIVITY);
request.setFrom("from.address");
request.setTo(component.jid);
final int wait = 2;
// do magic
component.start();
Thread.sleep(wait*1000);
component.processPacket(request);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertEquals(Type.result, result.getType());
assertEquals(String.valueOf(wait), result.getChildElement().attributeValue("seconds"));
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:32,代码来源:AbstractComponentTest.java
示例11: testEntityTime
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* This test verifies that the abstract component responds to XMPP Entity Time requests.
*/
@Test
public void testEntityTime() throws Exception {
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
component.initialize(new JID("sub.domain"), null);
final IQ request = new IQ(Type.get);
request.setChildElement("ping",
AbstractComponent.NAMESPACE_ENTITY_TIME);
request.setFrom("from.address");
request.setTo(component.jid);
// do magic
component.start();
component.processPacket(request);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertEquals(Type.result, result.getType());
// TODO although this test verifies that a result is produced, it also needs to verify the correctness of the content of the result.
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentTest.java
示例12: testSimpleResponse
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* A normal response is expected if an IQ request is sent that is processed
* by the component.
*/
@Test
public void testSimpleResponse() throws Exception {
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping",
AbstractComponent.NAMESPACE_XMPP_PING);
pingRequest.setFrom("from.address");
pingRequest.setTo("to.address");
// do magic
component.start();
component.processPacket(pingRequest);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertTrue(result.isResponse());
assertEquals(pingRequest.getID(), result.getID());
assertEquals(pingRequest.getFrom(), result.getTo());
assertEquals(pingRequest.getTo(), result.getFrom());
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentRespondsToIQRequestsTest.java
示例13: testNoImplementation
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* If no implementation is provided for a particular IQ request, a response (an error) should be returned.
*/
@Test
public void testNoImplementation() throws Exception
{
// setup
final DummyAbstractComponent component = new DummyAbstractComponent();
final IQ request = new IQ(Type.set);
request.setChildElement("junit", "test");
request.setFrom("from.address");
request.setTo("to.address");
// do magic
component.start();
component.processPacket(request);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertTrue(result.isResponse());
assertEquals(request.getID(), result.getID());
assertEquals(request.getFrom(), result.getTo());
assertEquals(request.getTo(), result.getFrom());
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:26,代码来源:AbstractComponentRespondsToIQRequestsTest.java
示例14: testExceptionResponse
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* If an exception is thrown during the processing of an IQ request,
* AbstractComponent should still return a response to the request.
*
* This test uses a AbstractComponent that throws an exception every time it
* processes an IQ get request.
*/
@Test
public void testExceptionResponse() throws Exception {
// setup
final DummyAbstractComponent component = new ThrowExceptionOnGetComponent();
final IQ request = new IQ(Type.get);
request.setChildElement("junit", "test");
request.setFrom("from.address");
request.setTo("to.address");
// do magic
component.start();
component.processPacket(request);
// verify
final IQ result = (IQ) component.getSentPacket();
assertNotNull(result);
assertTrue(result.isResponse());
assertEquals(request.getID(), result.getID());
assertEquals(request.getFrom(), result.getTo());
assertEquals(request.getTo(), result.getFrom());
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:29,代码来源:AbstractComponentRespondsToIQRequestsTest.java
示例15: handleIQ
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) {
if (Type.get.equals(packet.getType())) {
return IQ.createResultIQ(packet);
}
return null;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:IQPingHandler.java
示例16: sessionIdle
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* In addition to the functionality provided by the parent class, this
* method will send XMPP ping requests to the remote entity on every first
* invocation of this method (which will occur after a period of half the
* allowed connection idle time has passed, without any IO).
*
* XMPP entities must respond with either an IQ result or an IQ error
* (feature-unavailable) stanza upon receiving the XMPP ping stanza. Both
* responses will be received by Openfire and will cause the connection idle
* count to be reset.
*
* Entities that do not respond to the IQ Ping stanzas can be considered
* dead, and their connection will be closed by the parent class
* implementation on the second invocation of this method.
*
* Note that whitespace pings that are sent by XMPP entities will also cause
* the connection idle count to be reset.
*
* @see ConnectionHandler#sessionIdle(IoSession, IdleStatus)
*/
@Override
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
super.sessionIdle(session, status);
final boolean doPing = JiveGlobals.getBooleanProperty(ConnectionSettings.Client.KEEP_ALIVE_PING, true);
if (doPing && session.getIdleCount(status) == 1) {
final ClientStanzaHandler handler = (ClientStanzaHandler) session.getAttribute(HANDLER);
final JID entity = handler.getAddress();
if (entity != null) {
// Ping the connection to see if it is alive.
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping",
IQPingHandler.NAMESPACE);
pingRequest.setFrom( XMPPServer.getInstance().getServerInfo().getXMPPDomain() );
pingRequest.setTo(entity);
// Get the connection for this session
final Connection connection = (Connection) session.getAttribute(CONNECTION);
if (Log.isDebugEnabled()) {
Log.debug("ConnectionHandler: Pinging connection that has been idle: " + connection);
}
connection.deliver(pingRequest);
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:49,代码来源:ClientConnectionHandler.java
示例17: replyDisabled
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Constructs a IQ result stanza, based on the request stanza that is provided as an argument. The stanza tells the recipient that this
* service is currently unavailable.
*
* @param packet
* The request IQ stanza to which a result will be returned.
* @return A result stanza, telling the user that this service is unavailable.
*/
private static IQ replyDisabled(IQ packet) {
IQ replyPacket = IQ.createResultIQ(packet);
Element reply = replyPacket.setChildElement("query", NAMESPACE_JABBER_IQ_SEARCH);
final DataForm unavailableForm = new DataForm(DataForm.Type.cancel);
unavailableForm.setTitle(LocaleUtils.getLocalizedString("advance.user.search.title", "search"));
unavailableForm.addInstruction(LocaleUtils.getLocalizedString("search.service_unavailable", "search"));
reply.add(unavailableForm.getElement());
return replyPacket;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:SearchPlugin.java
示例18: replyDataFormResult
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Constructs a query that is returned as an IQ packet that contains the search results.
*
* @param users
* set of users that will be used to construct the search results
* @param packet
* the IQ packet sent by the client
* @return the iq packet that contains the search results
*/
private IQ replyDataFormResult(Collection<User> users, IQ packet) {
final DataForm searchResults = new DataForm(DataForm.Type.result);
searchResults.addField("FORM_TYPE", null, FormField.Type.hidden);
searchResults.addReportedField("jid", "JID", FormField.Type.jid_single);
for (final String fieldName : getFilteredSearchFields()) {
searchResults.addReportedField(fieldName,
LocaleUtils.getLocalizedString("advance.user.search." + fieldName.toLowerCase(), "search"), FormField.Type.text_single);
}
for (final User user : users) {
final String username = JID.unescapeNode(user.getUsername());
final Map<String, Object> item = new HashMap<String, Object>();
item.put("jid", username + "@" + serverName);
item.put(LocaleUtils.getLocalizedString("advance.user.search.username", "search"), username);
item.put(LocaleUtils.getLocalizedString("advance.user.search.name", "search"),
(user.isNameVisible() ? removeNull(user.getName()) : ""));
item.put(LocaleUtils.getLocalizedString("advance.user.search.email", "search"),
(user.isEmailVisible() ? removeNull(user.getEmail()) : ""));
searchResults.addItemFields(item);
}
IQ replyPacket = IQ.createResultIQ(packet);
Element reply = replyPacket.setChildElement("query", NAMESPACE_JABBER_IQ_SEARCH);
reply.add(searchResults.getElement());
return replyPacket;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:45,代码来源:SearchPlugin.java
示例19: sessionIdle
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* In addition to the functionality provided by the parent class, this
* method will send XMPP ping requests to the remote entity on every first
* invocation of this method (which will occur after a period of half the
* allowed connection idle time has passed, without any IO).
*
* XMPP entities must respond with either an IQ result or an IQ error
* (feature-unavailable) stanza upon receiving the XMPP ping stanza. Both
* responses will be received by Openfire and will cause the connection idle
* count to be reset.
*
* Entities that do not respond to the IQ Ping stanzas can be considered
* dead, and their connection will be closed by the parent class
* implementation on the second invocation of this method.
*
* Note that whitespace pings that are sent by XMPP entities will also cause
* the connection idle count to be reset.
*
* @see ConnectionHandler#sessionIdle(IoSession, IdleStatus)
*/
@Override
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
super.sessionIdle(session, status);
final boolean doPing = JiveGlobals.getBooleanProperty("xmpp.client.idle.ping", true);
if (doPing && session.getIdleCount(status) == 1) {
final ClientStanzaHandler handler = (ClientStanzaHandler) session.getAttribute(HANDLER);
final JID entity = handler.getAddress();
if (entity != null) {
// Ping the connection to see if it is alive.
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping",
IQPingHandler.NAMESPACE);
pingRequest.setFrom(serverName);
pingRequest.setTo(entity);
// Get the connection for this session
final Connection connection = (Connection) session.getAttribute(CONNECTION);
if (Log.isDebugEnabled()) {
Log.debug("ConnectionHandler: Pinging connection that has been idle: " + connection);
}
connection.deliver(pingRequest);
}
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:49,代码来源:ClientConnectionHandler.java
示例20: handleDiscoInfo
import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
* Creates a response specific to the search plugin to Disco#Info requests.
*
* @param iq
* The IQ stanza that contains the request.
* @return An IQ stanza, formulated as an answer to the received request.
*/
private static IQ handleDiscoInfo(IQ iq) {
if (iq == null) {
throw new IllegalArgumentException("Argument 'iq' cannot be null.");
}
if (!iq.getChildElement().getNamespaceURI().equals(
IQDiscoInfoHandler.NAMESPACE_DISCO_INFO)
|| iq.getType() != Type.get) {
throw new IllegalArgumentException(
"This is not a valid disco#info request.");
}
final IQ replyPacket = IQ.createResultIQ(iq);
final Element responseElement = replyPacket.setChildElement("query",
IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("identity").addAttribute("category",
"directory").addAttribute("type", "user").addAttribute("name",
"User Search");
responseElement.addElement("feature").addAttribute("var",
NAMESPACE_JABBER_IQ_SEARCH);
responseElement.addElement("feature").addAttribute("var",
IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
responseElement.addElement("feature").addAttribute("var",
ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT);
return replyPacket;
}
开发者ID:coodeer,项目名称:g3server,代码行数:36,代码来源:SearchPlugin.java
注:本文中的org.xmpp.packet.IQ.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论