use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class StreamNegotiator method initiateIncomingStream.
protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException {
final StreamInitiation response = createInitiationAccept(initiation, getNamespaces());
newStreamInitiation(initiation.getFrom(), initiation.getSessionID());
final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
IQ streamMethodInitiation;
try {
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() {
@Override
public void action() throws NotConnectedException {
try {
connection.sendStanza(response);
} catch (InterruptedException e) {
// Ignore
}
}
});
} catch (InterruptedException e) {
// TODO remove this try/catch once merged into 4.2's master branch
throw new IllegalStateException(e);
}
if (streamMethodInitiation == null) {
throw NoResponseException.newWith(connection, "stream initiation");
}
XMPPErrorException.ifHasErrorThenThrow(streamMethodInitiation);
return streamMethodInitiation;
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class FaultTolerantNegotiator method createIncomingStream.
@Override
public InputStream createIncomingStream(final StreamInitiation initiation) throws SmackException, XMPPErrorException, InterruptedException {
// This could be either an xep47 ibb 'open' iq or an xep65 streamhost iq
IQ initationSet = initiateIncomingStream(connection, initiation);
StreamNegotiator streamNegotiator = determineNegotiator(initationSet);
return streamNegotiator.negotiateIncomingStream(initationSet);
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class InBandBytestreamManager method replyRejectPacket.
/**
* Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream is
* not accepted.
*
* @param request IQ stanza(/packet) that should be answered with a not-acceptable error
* @throws NotConnectedException
* @throws InterruptedException
*/
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
IQ error = IQ.createErrorResponse(request, XMPPError.Condition.not_acceptable);
this.connection.sendStanza(error);
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class InBandBytestreamManager method replyResourceConstraintPacket.
/**
* Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream open
* request is rejected because its block size is greater than the maximum allowed block size.
*
* @param request IQ stanza(/packet) that should be answered with a resource-constraint error
* @throws NotConnectedException
* @throws InterruptedException
*/
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException, InterruptedException {
IQ error = IQ.createErrorResponse(request, XMPPError.Condition.resource_constraint);
this.connection.sendStanza(error);
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class LastActivityTest method checkProvider.
@Test
public void checkProvider() throws Exception {
XMLBuilder xml = XMLBuilder.create("iq");
xml.a("from", "romeo@montague.net/orchard").a("id", "last2").a("to", "juliet@capulet.com/balcony").a("type", "get").e("query").namespace(LastActivity.NAMESPACE);
DummyConnection c = new DummyConnection();
c.connect();
IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
assertTrue(lastRequest instanceof LastActivity);
c.processStanza(lastRequest);
Stanza reply = c.getSentPacket();
assertTrue(reply instanceof LastActivity);
LastActivity l = (LastActivity) reply;
assertEquals("last2", l.getStanzaId());
assertEquals(IQ.Type.result, l.getType());
}
Aggregations