本文整理汇总了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;
}
示例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());
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}