mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02:06 +01:00
A packet reply timeout can be set which applies to all methods (from Sid).
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10950 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
afe2b9b584
commit
ac2c9b09dc
1 changed files with 200 additions and 183 deletions
|
@ -61,6 +61,13 @@ public class RemoteCommand extends AdHocCommand {
|
|||
*/
|
||||
private String sessionID;
|
||||
|
||||
|
||||
/**
|
||||
* The number of milliseconds to wait for a response from the server
|
||||
* The default value is the default packet reply timeout (5000 ms).
|
||||
*/
|
||||
private long packetReplyTimeout;
|
||||
|
||||
/**
|
||||
* Creates a new RemoteCommand that uses an specific connection to execute a
|
||||
* command identified by <code>node</code> in the host identified by
|
||||
|
@ -75,34 +82,22 @@ public class RemoteCommand extends AdHocCommand {
|
|||
this.connection = connection;
|
||||
this.jid = jid;
|
||||
this.setNode(node);
|
||||
this.packetReplyTimeout = SmackConfiguration.getPacketReplyTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() throws XMPPException {
|
||||
executeAction(Action.cancel, SmackConfiguration.getPacketReplyTimeout());
|
||||
executeAction(Action.cancel, packetReplyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(Form form) throws XMPPException {
|
||||
executeAction(Action.complete, form, SmackConfiguration.getPacketReplyTimeout());
|
||||
executeAction(Action.complete, form, packetReplyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws XMPPException {
|
||||
executeAction(Action.execute, SmackConfiguration.getPacketReplyTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the command, waiting up to the <tt>timeout</tt> for a reply.
|
||||
* This is invoked only on the first stage of the
|
||||
* command. It is invoked on every command. If there is a problem executing
|
||||
* the command it throws an XMPPException.
|
||||
*
|
||||
* @param timeout the length of time in ms to wait for a reply.
|
||||
* @throws XMPPException if there is an error executing the command.
|
||||
*/
|
||||
public void execute(long timeout) throws XMPPException {
|
||||
executeAction(Action.execute, timeout);
|
||||
executeAction(Action.execute, packetReplyTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,21 +109,21 @@ public class RemoteCommand extends AdHocCommand {
|
|||
* @throws XMPPException if an error occurs.
|
||||
*/
|
||||
public void execute(Form form) throws XMPPException {
|
||||
executeAction(Action.execute, form, SmackConfiguration.getPacketReplyTimeout());
|
||||
executeAction(Action.execute, form, packetReplyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void next(Form form) throws XMPPException {
|
||||
executeAction(Action.next, form, SmackConfiguration.getPacketReplyTimeout());
|
||||
executeAction(Action.next, form, packetReplyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prev() throws XMPPException {
|
||||
executeAction(Action.prev, SmackConfiguration.getPacketReplyTimeout());
|
||||
executeAction(Action.prev, packetReplyTimeout);
|
||||
}
|
||||
|
||||
private void executeAction(Action action, long timeout) throws XMPPException {
|
||||
executeAction(action, null, timeout);
|
||||
private void executeAction(Action action, long packetReplyTimeout) throws XMPPException {
|
||||
executeAction(action, null, packetReplyTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,4 +176,26 @@ public class RemoteCommand extends AdHocCommand {
|
|||
public String getOwnerJID() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of milliseconds to wait for a respone. The
|
||||
* {@link SmackConfiguration#getPacketReplyTimeout default} value
|
||||
* should be adjusted for commands that can take a long time to execute.
|
||||
*
|
||||
* @return the number of milliseconds to wait for responses.
|
||||
*/
|
||||
public long getPacketReplyTimeout() {
|
||||
return packetReplyTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of milliseconds to wait for a respone. The
|
||||
* {@link SmackConfiguration#getPacketReplyTimeout default} value
|
||||
* should be adjusted for commands that can take a long time to execute.
|
||||
*
|
||||
* @param packetReplyTimeout the number of milliseconds to wait for responses.
|
||||
*/
|
||||
public void setPacketReplyTimeout(long packetReplyTimeout) {
|
||||
this.packetReplyTimeout = packetReplyTimeout;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue