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


Java Packet.getError方法代码示例

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


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

示例1: getReply

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的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

示例2: save

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的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:ice-coffee,项目名称:EIM,代码行数:29,代码来源:VCard.java

示例3: setRequest

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的package包/类
/**
 * Send the {@link Privacy} packet to the server in order to modify the server privacy and 
 * waits for the answer.
 * 
 * @param requestPrivacy is the {@link Privacy} packet configured properly whose xml will be sent
 * to the server.
 * @return a new {@link Privacy} with the data received from the server.
 * @exception XMPPException if the request or the answer failed, it raises an exception.
 */ 
private Packet setRequest(Privacy requestPrivacy) throws XMPPException {
	
	// The request is a get iq type
	requestPrivacy.setType(Privacy.Type.SET);
	requestPrivacy.setFrom(this.getUser());
	
	// Filter packets looking for an answer from the server.
	PacketFilter responseFilter = new PacketIDFilter(requestPrivacy.getPacketID());
       PacketCollector response = connection.createPacketCollector(responseFilter);
       
       // Send create & join packet.
       connection.sendPacket(requestPrivacy);
       
       // Wait up to a certain number of seconds for a reply.
       Packet privacyAnswer = response.nextResult(SmackConfiguration.getPacketReplyTimeout());
       
       // Stop queuing results
       response.cancel();

       // Interprete the result and answer the privacy only if it is valid
       if (privacyAnswer == null) {
           throw new XMPPException("No response from server.");
       } else if (privacyAnswer.getError() != null) {
           throw new XMPPException(privacyAnswer.getError());
       }
       return privacyAnswer;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:37,代码来源:PrivacyListManager.java

示例4: executeAction

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的package包/类
/**
 * Executes the <code>action</codo> with the <code>form</code>.
 * The action could be any of the available actions. The form must
 * be the anwser of the previous stage. It can be <tt>null</tt> if it is the first stage.
 *
 * @param action the action to execute.
 * @param form the form with the information.
 * @param timeout the amount of time to wait for a reply.
 * @throws XMPPException if there is a problem executing the command.
 */
private void executeAction(Action action, Form form, long timeout) throws XMPPException {
    // TODO: Check that all the required fields of the form were filled, if
    // TODO: not throw the corresponding exeption. This will make a faster response,
    // TODO: since the request is stoped before it's sent.
    AdHocCommandData data = new AdHocCommandData();
    data.setType(IQ.Type.SET);
    data.setTo(getOwnerJID());
    data.setNode(getNode());
    data.setSessionID(sessionID);
    data.setAction(action);

    if (form != null) {
        data.setForm(form.getDataFormToSend());
    }

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

    connection.sendPacket(data);

    Packet response = collector.nextResult(timeout);

    // 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());
    }

    AdHocCommandData responseData = (AdHocCommandData) response;
    this.sessionID = responseData.getSessionID();
    super.setData(responseData);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:46,代码来源:RemoteCommand.java

示例5: setRequest

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的package包/类
/**
 * Send the {@link Privacy} packet to the server in order to modify the server privacy and 
 * waits for the answer.
 * 
 * @param requestPrivacy is the {@link Privacy} packet configured properly whose xml will be sent
 * to the server.
 * @return a new {@link Privacy} with the data received from the server.
 * @exception XMPPException if the request or the answer failed, it raises an exception.
 */ 
private Packet setRequest(Privacy requestPrivacy) throws XMPPException {
       Connection connection = PrivacyListManager.this.connection.get();
       if (connection == null) throw new XMPPException("Connection instance already gc'ed");
	// The request is a get iq type
	requestPrivacy.setType(Privacy.Type.SET);
	requestPrivacy.setFrom(this.getUser());
	
	// Filter packets looking for an answer from the server.
	PacketFilter responseFilter = new PacketIDFilter(requestPrivacy.getPacketID());
       PacketCollector response = connection.createPacketCollector(responseFilter);
       
       // Send create & join packet.
       connection.sendPacket(requestPrivacy);
       
       // Wait up to a certain number of seconds for a reply.
       Packet privacyAnswer = response.nextResult(SmackConfiguration.getPacketReplyTimeout());
       
       // Stop queuing results
       response.cancel();

       // Interprete the result and answer the privacy only if it is valid
       if (privacyAnswer == null) {
           throw new XMPPException("No response from server.");
       } else if (privacyAnswer.getError() != null) {
           throw new XMPPException(privacyAnswer.getError());
       }
       return privacyAnswer;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:38,代码来源:PrivacyListManager.java

示例6: refreshRegisterInfo

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的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:CJC-ivotten,项目名称:androidPN-client.,代码行数:16,代码来源:Gateway.java

示例7: doLoad

import org.jivesoftware.smack.packet.Packet; //导入方法依赖的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;
    Packet packet = collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    if (packet == null) {
        String errorMessage = "Timeout getting VCard information";
        throw new XMPPException(errorMessage, new XMPPError(XMPPError.Condition.request_timeout, errorMessage));
    }
    if (packet.getError() != null) {
        throw new XMPPException(packet.getError());
    }

    try {
       result = (VCard) packet;
    }
    catch (ClassCastException e) {
        System.out.println("No VCard for " + user);
        return;
    }

    copyFieldsFrom(result);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:28,代码来源:VCard.java


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