mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-14 11:39:39 +02:00
Make sendPacket throw NotConnectedException
also use XMPPConnection.sendPacket() instead of PacketWriter.sendPacket() in XMPPTCPConnection.
This commit is contained in:
parent
7041e90522
commit
42f2eae8fb
5 changed files with 40 additions and 31 deletions
|
@ -17,12 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
|
@ -80,19 +80,18 @@ class PacketWriter {
|
|||
* Sends the specified packet to the server.
|
||||
*
|
||||
* @param packet the packet to send.
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendPacket(Packet packet) {
|
||||
public void sendPacket(Packet packet) throws NotConnectedException {
|
||||
if (done) {
|
||||
return;
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
try {
|
||||
queue.put(packet);
|
||||
}
|
||||
catch (InterruptedException ie) {
|
||||
LOGGER.log(Level.SEVERE,
|
||||
"Failed to queue packet to send to server: " + packet.toString(), ie);
|
||||
return;
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue