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


Java PacketCollector.nextResult方法代码示例

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


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

示例1: testRespondWithErrorOnInBandBytestreamRequest

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Target should respond with not-acceptable error if no listeners for incoming In-Band
 * Bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
    XMPPConnection targetConnection = getConnection(0);

    XMPPConnection initiatorConnection = getConnection(1);

    Open open = new Open("sessionID", 1024);
    open.setFrom(initiatorConnection.getUser());
    open.setTo(targetConnection.getUser());

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    open.getStanzaId()));
    initiatorConnection.sendStanza(open);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:InBandBytestreamTest.java

示例2: testRespondWithErrorOnSocks5BytestreamRequest

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Target should respond with not-acceptable error if no listeners for incoming Socks5
 * bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnSocks5BytestreamRequest() throws XMPPException {
    XMPPConnection targetConnection = getConnection(0);

    XMPPConnection initiatorConnection = getConnection(1);

    Bytestream bytestreamInitiation = Socks5PacketUtils.createBytestreamInitiation(
                    initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
    bytestreamInitiation.addStreamHost("proxy.localhost", "127.0.0.1", 7777);

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    bytestreamInitiation.getStanzaId()));
    initiatorConnection.sendStanza(bytestreamInitiation);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:Socks5ByteStreamTest.java

示例3: 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

示例4: doLoad

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
private void doLoad(Connection connection, String user) throws XMPPException {
    setType(Type.GET);
    PacketCollector collector = connection.createPacketCollector(
            new PacketIDFilter(getPacketID()));
    connection.sendPacket(this);

    VCard result = null;
    try {
        result = (VCard) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

        if (result == null) {
            String errorMessage = "Timeout getting VCard information";
            throw new XMPPException(errorMessage, new XMPPError(
                    XMPPError.Condition.request_timeout, errorMessage));
        }
        if (result.getError() != null) {
            throw new XMPPException(result.getError());
        }
    }
    catch (ClassCastException e) {
        System.out.println("No VCard for " + user);
    }

    copyFieldsFrom(result);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:26,代码来源:VCard.java

示例5: getSearchForm

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Returns the form for all search fields supported by the search service.
 *
 * @param con           the current Connection.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return the search form received by the server.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public Form getSearchForm(Connection con, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.GET);
    search.setTo(searchService);

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

    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 Form.getFormFrom(response);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:30,代码来源:UserSearch.java

示例6: sendRegistrationForm

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Sends the completed registration form to the server. After the user successfully submits
 * the form, the room may queue the request for review by the room admins or may immediately
 * add the user to the member list by changing the user's affiliation from "none" to "member.<p>
 *
 * If the desired room nickname is already reserved for that room, the room will return a
 * "Conflict" error to the user (error code 409). If the room does not support registration,
 * it will return a "Service Unavailable" error to the user (error code 503).
 *
 * @param form the completed registration form.
 * @throws XMPPException if an error occurs submitting the registration form. In particular, a
 *      409 error can occur if the desired room nickname is already reserved for that room;
 *      or a 503 error can occur if the room does not support registration.
 */
public void sendRegistrationForm(Form form) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(room);
    reg.addExtension(form.getDataFormToSend());

    PacketFilter filter =
        new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:MultiUserChat.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: getSharedGroups

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Returns the collection that will contain the name of the shared groups where the user
 * logged in with the specified session belongs.
 *
 * @param connection connection to use to get the user's shared groups.
 * @return collection with the shared groups' name of the logged user.
 */
public static List<String> getSharedGroups(Connection connection) throws XMPPException {
    // Discover the shared groups of the logged user
    SharedGroupsInfo info = new SharedGroupsInfo();
    info.setType(IQ.Type.GET);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(info.getPacketID()));

    connection.sendPacket(info);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return ((SharedGroupsInfo) result).getGroups();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:31,代码来源:SharedGroupManager.java

示例9: sendConfigurationForm

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Sends the completed configuration form to the server. The room will be configured
 * with the new settings defined in the form. If the form is empty then the server
 * will create an instant room (will use default configuration).
 *
 * @param form the form with the new settings.
 * @throws XMPPException if an error occurs setting the new rooms' configuration.
 */
public void sendConfigurationForm(Form form) throws XMPPException {
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.SET);
    iq.addExtension(form.getDataFormToSend());

    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(iq.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Send the completed 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());
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:32,代码来源:MultiUserChat.java

示例10: getReply

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

示例11: getReply

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
static public Packet getReply(Connection connection, Packet packet,
        long timeout) throws XMPPException {
    PacketFilter responseFilter = new PacketIDFilter(packet.getID());
    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(SmackError.NO_RESPONSE_FROM_SERVER);
    } else if (result.getError() != null) {
        throw new XMPPException(result.getError());
    }
    return result;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:22,代码来源:SyncPacketSend.java

示例12: getLastActivity

import org.jivesoftware.smack.PacketCollector; //导入方法依赖的package包/类
/**
 * Retrieve the last activity of a particular jid.
 * 
 * @param con
 *            the current Connection.
 * @param jid
 *            the JID of the user.
 * @return the LastActivity packet of the jid.
 * @throws XMPPException
 *             thrown if a server error has occured.
 * @deprecated This method only retreives the lapsed time since the last
 *             logout of a particular jid. Replaced by
 *             {@link org.jivesoftware.smackx.LastActivityManager#getLastActivity(Connection, String)
 *             getLastActivity}
 */
public static LastActivity getLastActivity(Connection con, String jid)
		throws XMPPException {
	LastActivity activity = new LastActivity();
	jid = StringUtils.parseBareAddress(jid);
	activity.setTo(jid);

	PacketCollector collector = con
			.createPacketCollector(new PacketIDFilter(activity
					.getPacketID()));
	con.sendPacket(activity);

	LastActivity response = (LastActivity) 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:ikantech,项目名称:xmppsupport_v2,代码行数:40,代码来源:LastActivity.java

示例13: 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

示例14: 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

示例15: getReply

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


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