static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
static public Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException { PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); connection.sendPacket(packet); // Wait up to a certain number of seconds for a reply. Packet result = response.nextResult(timeout); // Stop queuing results response.cancel(); if (result == null) { throw new XMPPException("No response from server."); } else if (result.getError() != null) { throw new XMPPException(result.getError()); } return result; }
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { long counter = 0; for (Packet packet : incomingPackets) { incomingPackets.remove(packet); SampleResult subRes = new SampleResult(); subRes.setSuccessful(true); subRes.setResponseCode("200"); subRes.setResponseMessage("OK"); subRes.setSampleLabel(packet.getClass().getSimpleName().isEmpty() ? packet.getClass().getName() : packet.getClass().getSimpleName()); subRes.setResponseData(packet.toXML().toString().getBytes()); if ((packet instanceof Presence) && (((Presence) packet).getType() == Presence.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } else if ((packet instanceof Message) && (((Message) packet).getType() == Message.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } else if ((packet instanceof IQ) && (((IQ) packet).getType() == IQ.Type.error)) { subRes.setSuccessful(false); subRes.setResponseCode("500"); subRes.setResponseMessage(packet.getError().toString()); } res.addSubResult(subRes); counter++; } res.setResponseData(("Received packets: " + counter).getBytes()); return counter > 0 ? res : null; }
public void processPacket(Packet packet) { if (packet == null || packet.getError() != null) { return;
public void processPacket(Packet packet) { if (packet == null || packet.getError() != null) { return;
@Override public void processPacket(Packet packet) throws SmackException.NotConnectedException { try { log.debug("Packet recv [" + conn.getConnectionID() + "]: " + packet.toXML()); } catch (IllegalArgumentException e) { log.debug("Failed to log packet", e); log.debug("Packet recv [" + conn.getConnectionID() + "]: " + packet.getError()); } } }
public void makeRoomOwner(Connection con, String sessionID) throws XMPPException { MonitorPacket request = new MonitorPacket(); request.setType(IQ.Type.SET); request.setTo(workgroupJID); request.setSessionID(sessionID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); connection.sendPacket(request); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } } }
public void makeRoomOwner(Connection con, String sessionID) throws XMPPException { MonitorPacket request = new MonitorPacket(); request.setType(IQ.Type.SET); request.setTo(workgroupJID); request.setSessionID(sessionID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); connection.sendPacket(request); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } } }
public void makeRoomOwner(Connection con, String sessionID) throws XMPPException { MonitorPacket request = new MonitorPacket(); request.setType(IQ.Type.SET); request.setTo(workgroupJID); request.setSessionID(sessionID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); connection.sendPacket(request); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } } }
/** * Save this vCard for the user connected by 'connection'. Connection should be authenticated * and not anonymous.<p> * <p/> * NOTE: the method is asynchronous and does not wait for the returned value. * * @param connection the Connection to use. * @throws XMPPException thrown if there was an issue setting the VCard in the server. */ public void save(Connection connection) throws XMPPException { checkAuthenticated(connection, true); setType(Type.SET); setFrom(connection.getUser()); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID())); connection.sendPacket(this); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
/** * Save this vCard for the user connected by 'connection'. Connection should be authenticated * and not anonymous.<p> * <p/> * NOTE: the method is asynchronous and does not wait for the returned value. * @param connection the XMPPConnection to use. * @throws XMPPException thrown if there was an issue setting the VCard in the server. */ public void save(XMPPConnection connection) throws XMPPException { checkAuthenticated(connection); setType(IQ.Type.SET); setFrom(connection.getUser()); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID())); connection.sendPacket(this); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
/** * Save this vCard for the user connected by 'connection'. Connection should be authenticated * and not anonymous.<p> * <p/> * NOTE: the method is asynchronous and does not wait for the returned value. * * @param connection the Connection to use. * @throws XMPPException thrown if there was an issue setting the VCard in the server. */ public void save(Connection connection) throws XMPPException { checkAuthenticated(connection, true); setType(IQ.Type.SET); setFrom(connection.getUser()); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID())); connection.sendPacket(this); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
/** * Save this vCard for the user connected by 'connection'. Connection should be authenticated * and not anonymous.<p> * <p/> * NOTE: the method is asynchronous and does not wait for the returned value. * * @param connection the Connection to use. * @throws XMPPException thrown if there was an issue setting the VCard in the server. */ public void save(Connection connection) throws XMPPException { checkAuthenticated(connection, true); setType(IQ.Type.SET); setFrom(connection.getUser()); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID())); connection.sendPacket(this); Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
private void refreshRegisterInfo(){ Registration packet = new Registration(); packet.setFrom(connection.getUser()); packet.setType(IQ.Type.GET); packet.setTo(entityJID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(packet.getPacketID())); connection.sendPacket(packet); Packet result = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); collector.cancel(); if(result instanceof Registration && result.getError()==null){ Registration register = (Registration)result; this.registerInfo = register; } }