mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-04 19:25:58 +01:00
Increased file transfer buffer size.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3701 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
8d3bf139c6
commit
a5b061d187
1 changed files with 13 additions and 16 deletions
|
@ -56,6 +56,11 @@ public abstract class FileTransfer {
|
||||||
|
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buffer size between input and output
|
||||||
|
*/
|
||||||
|
private static final int BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
protected FileTransfer(String peer, String streamID,
|
protected FileTransfer(String peer, String streamID,
|
||||||
FileTransferNegotiator negotiator) {
|
FileTransferNegotiator negotiator) {
|
||||||
this.peer = peer;
|
this.peer = peer;
|
||||||
|
@ -196,20 +201,13 @@ public abstract class FileTransfer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeToStream(final InputStream in, final OutputStream out)
|
protected void writeToStream(final InputStream in, final OutputStream out)
|
||||||
throws XMPPException {
|
throws XMPPException
|
||||||
final byte[] b = new byte[1000];
|
{
|
||||||
int count;
|
final byte[] b = new byte[BUFFER_SIZE];
|
||||||
|
int count = 0;
|
||||||
amountWritten = 0;
|
amountWritten = 0;
|
||||||
try {
|
|
||||||
count = in.read(b);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new XMPPException("error reading from input stream", e);
|
|
||||||
}
|
|
||||||
while (count != -1 && !getStatus().equals(Status.CANCLED)) {
|
|
||||||
if (getStatus().equals(Status.CANCLED)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
do {
|
||||||
// write to the output stream
|
// write to the output stream
|
||||||
try {
|
try {
|
||||||
out.write(b, 0, count);
|
out.write(b, 0, count);
|
||||||
|
@ -225,10 +223,9 @@ public abstract class FileTransfer {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new XMPPException("error reading from input stream", e);
|
throw new XMPPException("error reading from input stream", e);
|
||||||
}
|
}
|
||||||
}
|
} while (count != -1 && !getStatus().equals(Status.CANCLED));
|
||||||
|
|
||||||
// the connection was likely terminated abrubtly if these are not
|
// the connection was likely terminated abrubtly if these are not equal
|
||||||
// equal
|
|
||||||
if (!getStatus().equals(Status.CANCLED) && getError() == Error.NONE
|
if (!getStatus().equals(Status.CANCLED) && getError() == Error.NONE
|
||||||
&& amountWritten != fileSize) {
|
&& amountWritten != fileSize) {
|
||||||
setStatus(Status.ERROR);
|
setStatus(Status.ERROR);
|
||||||
|
|
Loading…
Reference in a new issue