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


Java PacketCollector.cancel方法代码示例

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


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

示例1: testGetServerVersion

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Get the version of the server and make sure that all the required data is present
 *
 * Note: This test expects the server to answer an iq:version packet.
 */
public void testGetServerVersion() {
    Version version = new Version();
    version.setType(IQ.Type.get);
    version.setTo(getServiceName());

    // Create a packet collector to listen for a response.
    PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getStanzaId()));

    getConnection(0).sendStanza(version);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ)collector.nextResult(5000);
    // Close the collector
    collector.cancel();

    assertNotNull("No result from the server", result);

    assertEquals("Incorrect result type", IQ.Type.result, result.getType());
    assertNotNull("No name specified in the result", ((Version)result).getName());
    assertNotNull("No version specified in the result", ((Version)result).getVersion());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:VersionTest.java

示例2: getName

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Return the agents name.
 *
 * @return - the agents name.
 */
public String getName() throws XMPPException {
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setType(IQ.Type.GET);
    agentInfo.setTo(workgroupJID);
    agentInfo.setFrom(getUser());
    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(agentInfo.getPacketID()));
    // Send the request
    connection.sendPacket(agentInfo);

    AgentInfo response = (AgentInfo)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());
    }
    return response.getName();
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:Agent.java

示例3: getConfigurationForm

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Returns the room's configuration form that the room's owner can use or <tt>null</tt> if
 * no configuration is possible. The configuration form allows to set the room's language,
 * enable logging, specify room's type, etc..
 *
 * @return the Form that contains the fields to complete together with the instrucions or
 * <tt>null</tt> if no configuration is possible.
 * @throws XMPPException if an error occurs asking the configuration form for the room.
 */
public Form getConfigurationForm() throws XMPPException {
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.GET);

    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(iq.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Request the configuration form to the server.
    connection.sendPacket(iq);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    }
    else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }
    return Form.getFormFrom(answer);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:33,代码来源:MultiUserChat.java

示例4: getTranscript

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Returns the full conversation transcript of a given session.
 *
 * @param sessionID the id of the session to get the full transcript.
 * @param workgroupJID the JID of the workgroup that will process the request.
 * @return the full conversation transcript of a given session.
 * @throws XMPPException if an error occurs while getting the information.
 */
public Transcript getTranscript(String workgroupJID, String sessionID) throws XMPPException {
    Transcript request = new Transcript(sessionID);
    request.setTo(workgroupJID);
    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID()));
    // Send the request
    connection.sendPacket(request);

    Transcript response = (Transcript) 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());
    }
    return response;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:28,代码来源:TranscriptManager.java

示例5: getWorkgroups

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
public static Collection<String> getWorkgroups(String serviceJID, String agentJID, Connection connection) throws XMPPException {
    AgentWorkgroups request = new AgentWorkgroups(agentJID);
    request.setTo(serviceJID);
    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID()));
    // Send the request
    connection.sendPacket(request);

    AgentWorkgroups response = (AgentWorkgroups)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());
    }
    return response.getWorkgroups();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:20,代码来源:Agent.java

示例6: setName

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Changes the name of the agent in the server. The server may have this functionality
 * disabled for all the agents or for this agent in particular. If the agent is not
 * allowed to change his name then an exception will be thrown with a service_unavailable
 * error code.
 *
 * @param newName the new name of the agent.
 * @throws XMPPException if the agent is not allowed to change his name or no response was
 *                       obtained from the server.
 */
public void setName(String newName) throws XMPPException {
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setType(IQ.Type.SET);
    agentInfo.setTo(workgroupJID);
    agentInfo.setFrom(getUser());
    agentInfo.setName(newName);
    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(agentInfo.getPacketID()));
    // Send the request
    connection.sendPacket(agentInfo);

    IQ response = (IQ)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());
    }
    return;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:33,代码来源:Agent.java

示例7: deleteMessages

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Deletes the specified list of offline messages. The request will include the list of
 * stamps that uniquely identifies the offline messages to delete.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public void deleteMessages(List<String> nodes) throws XMPPException {
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("remove");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Send the deletion request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:32,代码来源:OfflineMessageManager.java

示例8: setCarbonsEnabled

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Notify server to change the carbons state. This method blocks
 * some time until the server replies to the IQ and returns true on
 * success.
 *
 * You should first check for support using isSupportedByServer().
 *
 * @param new_state whether carbons should be enabled or disabled
 *
 * @return true if the operation was successful
 */
public boolean setCarbonsEnabled(final boolean new_state) {
    if (enabled_state == new_state)
        return true;

    IQ setIQ = carbonsEnabledIQ(new_state);

    PacketCollector collector =
            connection.createPacketCollector(new PacketIDFilter(setIQ.getPacketID()));
    connection.sendPacket(setIQ);
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();

    if (result != null && result.getType() == IQ.Type.RESULT) {
        enabled_state = new_state;
        return true;
    }
    return false;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:30,代码来源:CarbonManager.java

示例9: submitSearch

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) 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());
    }
    return ReportedData.getReportedDataFrom(response);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:32,代码来源:TranscriptSearchManager.java

示例10: save

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:29,代码来源:VCard.java

示例11: getSearchForm

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Returns the Form to use for searching transcripts. It is unlikely that
 * the server will change the form (without a restart) so it is safe to keep
 * the returned form for future submissions.
 * 
 * @param serviceJID
 *            the address of the workgroup service.
 * @return the Form to use for searching transcripts.
 * @throws XMPPException
 *             if an error occurs while sending the request to the server.
 */
public Form getSearchForm(String serviceJID) throws XMPPException {
	TranscriptSearch search = new TranscriptSearch();
	search.setType(IQ.Type.GET);
	search.setTo(serviceJID);

	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(search.getPacketID()));
	connection.sendPacket(search);

	TranscriptSearch response = (TranscriptSearch) 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());
	}
	return Form.getFormFrom(response);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:34,代码来源:TranscriptSearchManager.java

示例12: initiateIncomingStream

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
Packet initiateIncomingStream(Connection connection,
		StreamInitiation initiation) throws XMPPException {
	StreamInitiation response = createInitiationAccept(initiation,
			getNamespaces());

	// establish collector to await response
	PacketCollector collector = connection
			.createPacketCollector(getInitiationPacketFilter(
					initiation.getFrom(), initiation.getSessionID()));
	connection.sendPacket(response);

	Packet streamMethodInitiation = collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (streamMethodInitiation == null) {
		throw new XMPPException("No response from file transfer initiator");
	}

	return streamMethodInitiation;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:21,代码来源:StreamNegotiator.java

示例13: setName

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Changes the name of the agent in the server. The server may have this
 * functionality disabled for all the agents or for this agent in
 * particular. If the agent is not allowed to change his name then an
 * exception will be thrown with a service_unavailable error code.
 * 
 * @param newName
 *            the new name of the agent.
 * @throws XMPPException
 *             if the agent is not allowed to change his name or no response
 *             was obtained from the server.
 */
public void setName(String newName) throws XMPPException {
	AgentInfo agentInfo = new AgentInfo();
	agentInfo.setType(IQ.Type.SET);
	agentInfo.setTo(workgroupJID);
	agentInfo.setFrom(getUser());
	agentInfo.setName(newName);
	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(agentInfo
					.getPacketID()));
	// Send the request
	connection.sendPacket(agentInfo);

	IQ response = (IQ) 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());
	}
	return;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:38,代码来源:Agent.java

示例14: getWorkgroups

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
public static Collection<String> getWorkgroups(String serviceJID,
		String agentJID, Connection connection) throws XMPPException {
	AgentWorkgroups request = new AgentWorkgroups(agentJID);
	request.setTo(serviceJID);
	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(request.getPacketID()));
	// Send the request
	connection.sendPacket(request);

	AgentWorkgroups response = (AgentWorkgroups) 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());
	}
	return response.getWorkgroups();
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:23,代码来源:Agent.java

示例15: refreshRegisterInfo

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
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;
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:17,代码来源:Gateway.java


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