private EntityTimeManager(XMPPConnection connection) { super(connection); if (autoEnable) enable(); connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get, Mode.async) { @Override public IQ handleIQRequest(IQ iqRequest) { if (enabled) { return Time.createResponse(iqRequest); } else { return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable)); } } }); }
/** * Creates a file transfer manager to initiate and receive file transfers. * * @param connection * The XMPPConnection that the file transfers will use. */ private FileTransferManager(XMPPConnection connection) { super(connection); this.fileTransferNegotiator = FileTransferNegotiator .getInstanceFor(connection); connection.registerIQRequestHandler(new AbstractIqRequestHandler(StreamInitiation.ELEMENT, StreamInitiation.NAMESPACE, IQ.Type.set, Mode.async) { @Override public IQ handleIQRequest(IQ packet) { StreamInitiation si = (StreamInitiation) packet; final FileTransferRequest request = new FileTransferRequest(FileTransferManager.this, si); for (final FileTransferListener listener : listeners) { listener.fileTransferRequest(request); } return null; } }); }
private VersionManager(final XMPPConnection connection) { super(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); sdm.addFeature(Version.NAMESPACE); connection.registerIQRequestHandler(new AbstractIqRequestHandler(Version.ELEMENT, Version.NAMESPACE, IQ.Type.get, Mode.async) { @Override public IQ handleIQRequest(IQ iqRequest) { if (ourVersion == null) { return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable)); } return Version.createResultFor(iqRequest, ourVersion); } }); }
private AdHocCommandManager(XMPPConnection connection) { super(connection); this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection); // Add the feature to the service discovery manage to show that this // connection supports the AdHoc-Commands protocol. // This information will be used when another client tries to // discover whether this client supports AdHoc-Commands or not. ServiceDiscoveryManager.getInstanceFor(connection).addFeature( NAMESPACE); // Set the NodeInformationProvider that will provide information about // which AdHoc-Commands are registered, whenever a disco request is // received ServiceDiscoveryManager.getInstanceFor(connection) .setNodeInformationProvider(NAMESPACE, new AbstractNodeInformationProvider() { @Override public List<DiscoverItems.Item> getNodeItems() { List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>(); Collection<AdHocCommandInfo> commandsList = getRegisteredCommands(); for (AdHocCommandInfo info : commandsList) { DiscoverItems.Item item = new DiscoverItems.Item( info.getOwnerJID()); item.setName(info.getName()); item.setNode(info.getNode()); answer.add(item); } return answer; } }); // The packet listener and the filter for processing some AdHoc Commands // Packets connection.registerIQRequestHandler(new AbstractIqRequestHandler(AdHocCommandData.ELEMENT, AdHocCommandData.NAMESPACE, IQ.Type.set, Mode.async) { @Override public IQ handleIQRequest(IQ iqRequest) { AdHocCommandData requestData = (AdHocCommandData) iqRequest; try { return processAdHocCommand(requestData); } catch (NoResponseException | NotConnectedException e) { LOGGER.log(Level.INFO, "processAdHocCommand threw exceptino", e); return null; } } }); sessionsSweeper = null; }