1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 07:42:06 +01:00

Add XMPPConnection.sendStanza(Stanza)

and deprecate sendPacket().
This commit is contained in:
Florian Schmaus 2015-03-04 21:44:43 +01:00
parent 183af99ffb
commit ed4fa3390f
58 changed files with 183 additions and 167 deletions

View file

@ -98,7 +98,7 @@ your presence to let people know you're unavailable and "out fishing":
Presence presence = new Presence(Presence.Type.unavailable);
presence.setStatus("Gone fishing");
// Send the packet (assume we have an XMPPConnection instance called "con").
con.sendPacket(presence);
con.sendStanza(presence);
```
Smack provides two ways to read incoming packets: `PacketListener`, and

View file

@ -255,7 +255,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
}
@Override
protected void sendPacketInternal(Stanza packet) throws NotConnectedException {
protected void sendStanzaInternal(Stanza packet) throws NotConnectedException {
sendElement(packet);
}
@ -267,7 +267,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
}
}
catch (BOSHException e) {
LOGGER.log(Level.SEVERE, "BOSHException in sendPacketInternal", e);
LOGGER.log(Level.SEVERE, "BOSHException in sendStanzaInternal", e);
}
}

View file

@ -54,7 +54,7 @@ public class IQTest extends SmackTestCase {
new StanzaTypeFilter(IQ.class));
PacketCollector collector = getConnection(0).createPacketCollector(filter);
// Send the iq packet with an invalid namespace
getConnection(0).sendPacket(iq);
getConnection(0).sendStanza(iq);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
@ -85,7 +85,7 @@ public class IQTest extends SmackTestCase {
PacketCollector collector = getConnection(0).createPacketCollector(
new PacketIDFilter(versionRequest.getStanzaId()));
getConnection(0).sendPacket(versionRequest);
getConnection(0).sendStanza(versionRequest);
// Wait up to 5 seconds for a result.
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

View file

@ -42,11 +42,11 @@ public class MessageTest extends SmackTestCase {
* message?
*/
public void testDirectPresence() {
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
Presence presence = new Presence(Presence.Type.available);
presence.setTo(getBareJID(1));
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
PacketCollector collector = getConnection(0)
.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
@ -67,10 +67,10 @@ public class MessageTest extends SmackTestCase {
* the client becomes available again the offline messages are received.
*/
public void testOfflineMessage() {
getConnection(0).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(0).sendStanza(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// Make user2 unavailable
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
try {
Thread.sleep(500);
@ -86,7 +86,7 @@ public class MessageTest extends SmackTestCase {
// User2 becomes available again
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// Check that offline messages are retrieved by user2 which is now available
Message message = (Message) collector.nextResult(2500);
@ -112,7 +112,7 @@ public class MessageTest extends SmackTestCase {
*/
/*public void testOfflineMessageInvalidXML() {
// Make user2 unavailable
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
try {
Thread.sleep(500);
@ -128,7 +128,7 @@ public class MessageTest extends SmackTestCase {
// User2 becomes available again
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// Check that offline messages are retrieved by user2 which is now available
Message message = (Message) collector.nextResult(2500);
@ -150,8 +150,8 @@ public class MessageTest extends SmackTestCase {
* connections are not being closed.
*/
public void testHugeMessage() {
getConnection(0).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(0).sendStanza(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
new MessageTypeFilter(Message.Type.chat));
@ -165,7 +165,7 @@ public class MessageTest extends SmackTestCase {
msg.setBody(sb.toString());
// Send the first message
getConnection(0).sendPacket(msg);
getConnection(0).sendStanza(msg);
// Check that the connection that sent the message is still connected
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
// Check that the message was received
@ -173,7 +173,7 @@ public class MessageTest extends SmackTestCase {
assertNotNull("No Message was received", rcv);
// Send the second message
getConnection(0).sendPacket(msg);
getConnection(0).sendStanza(msg);
// Check that the connection that sent the message is still connected
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
// Check that the second message was received
@ -200,11 +200,11 @@ public class MessageTest extends SmackTestCase {
// Set this connection as highest priority
Presence presence = new Presence(Presence.Type.available);
presence.setPriority(10);
conn3.sendPacket(presence);
conn3.sendStanza(presence);
// Set this connection as highest priority
presence = new Presence(Presence.Type.available);
presence.setPriority(5);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
// Let the server process the change in presences
Thread.sleep(200);
@ -249,11 +249,11 @@ public class MessageTest extends SmackTestCase {
// Set this connection as highest priority
Presence presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.away);
conn3.sendPacket(presence);
conn3.sendStanza(presence);
// Set this connection as highest priority
presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
// Let the server process the change in presences
Thread.sleep(200);
@ -299,12 +299,12 @@ public class MessageTest extends SmackTestCase {
Presence presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
presence.setPriority(10);
conn3.sendPacket(presence);
conn3.sendStanza(presence);
// Set this connection as highest priority
presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
presence.setPriority(10);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
connectionConfiguration =
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
@ -314,7 +314,7 @@ public class MessageTest extends SmackTestCase {
presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
presence.setPriority(4);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
// Let the server process the change in presences
@ -326,7 +326,7 @@ public class MessageTest extends SmackTestCase {
PacketCollector coll4 = conn4.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
// Send a message from this resource to indicate most recent activity
conn3.sendPacket(new Message("admin@" + getServiceName()));
conn3.sendStanza(new Message("admin@" + getServiceName()));
// User1 sends a message to the bare JID of User0
Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null);
@ -362,7 +362,7 @@ public class MessageTest extends SmackTestCase {
Presence presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
presence.setPriority(-1);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
// Let the server process the change in presences
Thread.sleep(200);
@ -383,7 +383,7 @@ public class MessageTest extends SmackTestCase {
presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
presence.setPriority(1);
getConnection(0).sendPacket(presence);
getConnection(0).sendStanza(presence);
// Let the server process the change in presences
Thread.sleep(200);

View file

@ -84,7 +84,7 @@ public class PacketReaderTest extends SmackTestCase {
// Send the IQ and wait for the answer
PacketCollector collector = getConnection(0).createPacketCollector(
new PacketIDFilter(iqPacket.getStanzaId()));
getConnection(0).sendPacket(iqPacket);
getConnection(0).sendStanza(iqPacket);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
if (response == null) {
fail("No response from the other user.");
@ -114,7 +114,7 @@ public class PacketReaderTest extends SmackTestCase {
Message msg = new Message(getConnection(0).getUser(), Message.Type.normal);
getConnection(1).sendPacket(msg);
getConnection(1).sendStanza(msg);
// Remove the listener
getConnection(0).removeAsyncPacketListener(listener);
@ -141,7 +141,7 @@ public class PacketReaderTest extends SmackTestCase {
Message message = new Message(packet.getFrom());
message.setFrom(getFullJID(1));
message.setBody("HELLO");
getConnection(1).sendPacket(message);
getConnection(1).sendStanza(message);
}
}, new StanzaTypeFilter(Message.class));
@ -149,7 +149,7 @@ public class PacketReaderTest extends SmackTestCase {
PacketCollector collector = getConnection(0).createPacketCollector(
new FromMatchesFilter(getFullJID(1)));
// User0 sends the regular message to user1
getConnection(0).sendPacket(packet);
getConnection(0).sendStanza(packet);
// Check that user0 got a reply from user1
assertNotNull("No message was received", collector.nextResult(1000));
@ -159,7 +159,7 @@ public class PacketReaderTest extends SmackTestCase {
packet.setTo(getFullJID(1));
packet.setBody("aloha");
packet.setError(new XMPPError(XMPPError.Condition.feature_not_implemented, null));
getConnection(0).sendPacket(packet);
getConnection(0).sendStanza(packet);
// Check that user0 got a reply from user1
assertNotNull("No message was received", collector.nextResult(1000));
}
@ -213,8 +213,8 @@ public class PacketReaderTest extends SmackTestCase {
for (int i = 0; i < 5; i++) {
getConnection(1).sendPacket(msg0);
getConnection(0).sendPacket(msg1);
getConnection(1).sendStanza(msg0);
getConnection(0).sendStanza(msg1);
}
try {
@ -236,8 +236,8 @@ public class PacketReaderTest extends SmackTestCase {
}
for (int i = 0; i < 10; i++) {
getConnection(0).sendPacket(msg1);
getConnection(1).sendPacket(msg0);
getConnection(0).sendStanza(msg1);
getConnection(1).sendStanza(msg0);
}
try {

View file

@ -46,9 +46,9 @@ public class PresenceTest extends SmackTestCase {
conn.connect();
conn.login(getUsername(1), getUsername(1), "OtherPlace");
// Change the presence priorities of User_1
getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 1,
getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 1,
Presence.Mode.available));
conn.sendPacket(new Presence(Presence.Type.available, null, 2,
conn.sendStanza(new Presence(Presence.Type.available, null, 2,
Presence.Mode.available));
Thread.sleep(150);
// Create the chats between the participants
@ -64,9 +64,9 @@ public class PresenceTest extends SmackTestCase {
chat1.nextMessage(1000));*/
// Invert the presence priorities of User_1
getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 2,
getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 2,
Presence.Mode.available));
conn.sendPacket(new Presence(Presence.Type.available, null, 1,
conn.sendStanza(new Presence(Presence.Type.available, null, 1,
Presence.Mode.available));
Thread.sleep(150);
@ -86,14 +86,14 @@ public class PresenceTest extends SmackTestCase {
/*assertNotNull("Resource with highest priority didn't receive the message",
chat1.nextMessage(2000));*/
getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 2,
getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 2,
Presence.Mode.available));
// User_1 will log in again using another resource
conn = createConnection();
conn.connect();
conn.login(getUsername(1), getPassword(1), "OtherPlace");
conn.sendPacket(new Presence(Presence.Type.available, null, 1,
conn.sendStanza(new Presence(Presence.Type.available, null, 1,
Presence.Mode.available));
chat2 = conn.getChatManager().createChat(getBareJID(0), chat0.getThreadID(), null);
@ -106,9 +106,9 @@ public class PresenceTest extends SmackTestCase {
chat2.nextMessage(1000));*/
// Invert the presence priorities of User_1
getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 1,
getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 1,
Presence.Mode.available));
conn.sendPacket(new Presence(Presence.Type.available, null, 2,
conn.sendStanza(new Presence(Presence.Type.available, null, 2,
Presence.Mode.available));
Thread.sleep(150);
@ -139,7 +139,7 @@ public class PresenceTest extends SmackTestCase {
*/
public void testNotAvailablePresence() throws XMPPException {
// Change the presence to unavailable of User_1
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
// User_1 will log in again using another resource (that is going to be available)
XMPPTCPConnection conn = createConnection();

View file

@ -325,7 +325,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public abstract boolean isSecureConnection();
protected abstract void sendPacketInternal(Stanza packet) throws NotConnectedException;
protected abstract void sendStanzaInternal(Stanza packet) throws NotConnectedException;
@Override
public abstract void send(PlainStreamElement element) throws NotConnectedException;
@ -538,7 +538,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// eventually load the roster. And we should load the roster before we
// send the initial presence.
if (config.isSendPresence() && !resumed) {
sendPacket(new Presence(Presence.Type.available));
sendStanza(new Presence(Presence.Type.available));
}
}
@ -596,8 +596,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}
@Deprecated
@Override
public void sendPacket(Stanza packet) throws NotConnectedException {
sendStanza(packet);
}
@Override
public void sendStanza(Stanza packet) throws NotConnectedException {
Objects.requireNonNull(packet, "Packet must not be null");
throwNotConnectedExceptionIfAppropriate();
@ -615,7 +621,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// Invoke interceptors for the new packet that is about to be sent. Interceptors may modify
// the content of the packet.
firePacketInterceptors(packet);
sendPacketInternal(packet);
sendStanzaInternal(packet);
}
/**
@ -656,7 +662,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws NotConnectedException
*/
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
sendPacket(unavailablePresence);
sendStanza(unavailablePresence);
shutdown();
callConnectionClosedListener();
}
@ -694,7 +700,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
PacketCollector packetCollector = createPacketCollector(packetFilter);
try {
// Now we can send the packet as the collector has been created
sendPacket(packet);
sendStanza(packet);
}
catch (NotConnectedException | RuntimeException e) {
packetCollector.cancel();
@ -1023,7 +1029,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
ErrorIQ errorIQ = IQ.createErrorResponse(iq, new XMPPError(
XMPPError.Condition.feature_not_implemented));
try {
sendPacket(errorIQ);
sendStanza(errorIQ);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "NotConnectedException while sending error IQ to unkown IQ request", e);
@ -1052,7 +1058,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return;
}
try {
sendPacket(response);
sendStanza(response);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "NotConnectedException while sending response to IQ request", e);
@ -1433,7 +1439,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}, timeout, TimeUnit.MILLISECONDS);
addAsyncStanzaListener(packetListener, replyFilter);
sendPacket(stanza);
sendStanza(stanza);
}
@Override

View file

@ -62,7 +62,7 @@ public class SynchronizationPoint<E extends Exception> {
try {
if (request != null) {
if (request instanceof Stanza) {
connection.sendPacket((Stanza) request);
connection.sendStanza((Stanza) request);
}
else if (request instanceof PlainStreamElement){
connection.send((PlainStreamElement) request);

View file

@ -158,9 +158,19 @@ public interface XMPPConnection {
*
* @param packet the packet to send.
* @throws NotConnectedException
* @deprecated use {@link #sendStanza(Stanza)} instead.
*/
@Deprecated
public void sendPacket(Stanza packet) throws NotConnectedException;
/**
* Sends the specified stanza to the server.
*
* @param stanza the stanza to send.
* @throws NotConnectedException if the connection is not connected.
*/
public void sendStanza(Stanza stanza) throws NotConnectedException;
/**
* Send a PlainStreamElement.
* <p>

View file

@ -33,7 +33,7 @@ import org.jivesoftware.smack.packet.TopLevelStreamElement;
* unit tests.
*
* Instances store any packets that are delivered to be send using the
* {@link #sendPacket(Stanza)} method in a blocking queue. The content of this queue
* {@link #sendStanza(Stanza)} method in a blocking queue. The content of this queue
* can be inspected using {@link #getSentPacket()}. Typically these queues are
* used to retrieve a message that was generated by the client.
*
@ -132,7 +132,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
@Override
protected void sendPacketInternal(Stanza packet) {
protected void sendStanzaInternal(Stanza packet) {
if (SmackConfiguration.DEBUG) {
System.out.println("[SEND]: " + packet.toXML());
}
@ -140,7 +140,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
/**
* Returns the number of packets that's sent through {@link #sendPacket(Stanza)} and
* Returns the number of packets that's sent through {@link #sendStanza(Stanza)} and
* that has not been returned by {@link #getSentPacket()}.
*
* @return the number of packets which are in the queue.
@ -150,7 +150,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
/**
* Returns the first packet that's sent through {@link #sendPacket(Stanza)}
* Returns the first packet that's sent through {@link #sendStanza(Stanza)}
* and that has not been returned by earlier calls to this method.
*
* @return a sent packet.
@ -160,7 +160,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
/**
* Returns the first packet that's sent through {@link #sendPacket(Stanza)}
* Returns the first packet that's sent through {@link #sendStanza(Stanza)}
* and that has not been returned by earlier calls to this method. This
* method will block for up to the specified number of seconds if no packets
* have been sent yet.

View file

@ -38,8 +38,8 @@ public class ThreadedDummyConnection extends DummyConnection {
private volatile boolean timeout = false;
@Override
public void sendPacket(Stanza packet) throws NotConnectedException {
super.sendPacket(packet);
public void sendStanza(Stanza packet) throws NotConnectedException {
super.sendStanza(packet);
if (packet instanceof IQ && !timeout) {
timeout = false;
@ -62,7 +62,7 @@ public class ThreadedDummyConnection extends DummyConnection {
}
/**
* Calling this method will cause the next sendPacket call with an IQ packet to timeout.
* Calling this method will cause the next sendStanza call with an IQ packet to timeout.
* This is accomplished by simply stopping the auto creating of the reply packet
* or processing one that was entered via {@link #processPacket(Stanza)}.
*/

View file

@ -578,7 +578,7 @@ public class EnhancedDebugger implements SmackDebugger {
if (!"".equals(adhocMessages.getText())) {
AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
try {
connection.sendPacket(packetToSend);
connection.sendStanza(packetToSend);
}
catch (NotConnectedException e1) {
e1.printStackTrace();

View file

@ -61,7 +61,7 @@ public class CompressionTest extends SmackTestCase {
// Create a packet collector to listen for a response.
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(version.getStanzaId()));
connection.sendPacket(version);
connection.sendStanza(version);
// Wait up to 5 seconds for a result.
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

View file

@ -123,7 +123,7 @@ public class FormTest extends SmackTestCase {
// Add the completed form to the message
msg2.addExtension(completedForm.getDataFormToSend());
// Send the message with the completed form
getConnection(1).sendPacket(msg2);
getConnection(1).sendStanza(msg2);
// Get the message with the completed form
Message msg3 = (Message) collector.nextResult(2000);

View file

@ -46,7 +46,7 @@ public class GroupChatInvitationTest extends SmackTestCase {
Message message = new Message(getBareJID(1));
message.setBody("Group chat invitation!");
message.addExtension(invitation);
getConnection(0).sendPacket(message);
getConnection(0).sendStanza(message);
Thread.sleep(250);

View file

@ -35,7 +35,7 @@ public class LastActivityManagerTest extends SmackTestCase {
// Send a message as the last activity action from connection 1 to
// connection 0
conn1.sendPacket(new Message(getBareJID(0)));
conn1.sendStanza(new Message(getBareJID(0)));
// Wait 1 seconds to have some idle time
try {
@ -70,7 +70,7 @@ public class LastActivityManagerTest extends SmackTestCase {
// Send a message as the last activity action from connection 2 to
// connection 0
conn2.sendPacket(new Message(getBareJID(0)));
conn2.sendStanza(new Message(getBareJID(0)));
// Wait 1 seconds to have some idle time
try {

View file

@ -55,7 +55,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
*/
public void testReadAndDelete() {
// Make user2 unavailable
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
try {
Thread.sleep(500);
@ -100,7 +100,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
new MessageTypeFilter(Message.Type.chat));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// Check that no offline messages was sent to the user
Message message = (Message) collector.nextResult(2500);
@ -124,7 +124,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
*/
public void testFetchAndPurge() {
// Make user2 unavailable
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
try {
Thread.sleep(500);
@ -158,7 +158,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
new MessageTypeFilter(Message.Type.chat));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// Check that no offline messages was sent to the user
Message message = (Message) collector.nextResult(2500);

View file

@ -47,7 +47,7 @@ public class VersionTest extends SmackTestCase {
// Create a packet collector to listen for a response.
PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getStanzaId()));
getConnection(0).sendPacket(version);
getConnection(0).sendStanza(version);
// Wait up to 5 seconds for a result.
IQ result = (IQ)collector.nextResult(5000);

View file

@ -63,7 +63,7 @@ public class InBandBytestreamTest extends SmackTestCase {
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
open.getStanzaId()));
initiatorConnection.sendPacket(open);
initiatorConnection.sendStanza(open);
Packet result = collector.nextResult();
assertNotNull(result.getError());

View file

@ -84,7 +84,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
bytestreamInitiation.getStanzaId()));
initiatorConnection.sendPacket(bytestreamInitiation);
initiatorConnection.sendStanza(bytestreamInitiation);
Packet result = collector.nextResult();
assertNotNull(result.getError());

View file

@ -102,7 +102,7 @@ public class MultipleRecipientManager {
&& StringUtils.isNullOrEmpty(replyTo) && StringUtils.isNullOrEmpty(replyRoom)) {
String toJid = to.iterator().next();
packet.setTo(toJid);
connection.sendPacket(packet);
connection.sendStanza(packet);
return;
}
String serviceAddress = getMultipleRecipienServiceAddress(connection);
@ -155,7 +155,7 @@ public class MultipleRecipientManager {
if (replyAddress != null && replyAddress.getJid() != null) {
// Send reply to the reply_to address
reply.setTo(replyAddress.getJid());
connection.sendPacket(reply);
connection.sendStanza(reply);
}
else {
// Send reply to multiple recipients
@ -203,19 +203,19 @@ public class MultipleRecipientManager {
if (to != null) {
for (String jid : to) {
packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML()));
connection.sendStanza(new PacketCopy(packet.toXML()));
}
}
if (cc != null) {
for (String jid : cc) {
packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML()));
connection.sendStanza(new PacketCopy(packet.toXML()));
}
}
if (bcc != null) {
for (String jid : bcc) {
packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML()));
connection.sendStanza(new PacketCopy(packet.toXML()));
}
}
}
@ -258,7 +258,7 @@ public class MultipleRecipientManager {
// Add extension to packet
packet.addExtension(multipleAddresses);
// Send the packet
connection.sendPacket(packet);
connection.sendStanza(packet);
}
/**

View file

@ -442,7 +442,7 @@ public class InBandBytestreamManager implements BytestreamManager {
protected void replyRejectPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
this.connection.sendStanza(error);
}
/**
@ -455,7 +455,7 @@ public class InBandBytestreamManager implements BytestreamManager {
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
this.connection.sendStanza(error);
}
/**
@ -468,7 +468,7 @@ public class InBandBytestreamManager implements BytestreamManager {
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
this.connection.sendStanza(error);
}
/**

View file

@ -79,7 +79,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
// acknowledge request
IQ resultIQ = IQ.createResultIQ(this.byteStreamRequest);
connection.sendPacket(resultIQ);
connection.sendStanza(resultIQ);
return ibbSession;
}

View file

@ -173,7 +173,7 @@ public class InBandBytestreamSession implements BytestreamSession {
// acknowledge close request
IQ confirmClose = IQ.createResultIQ(closeRequest);
this.connection.sendPacket(confirmClose);
this.connection.sendStanza(confirmClose);
}
@ -457,7 +457,7 @@ public class InBandBytestreamSession implements BytestreamSession {
if (data.getSeq() <= this.lastSequence) {
IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
XMPPError.Condition.unexpected_request));
connection.sendPacket(unexpectedRequest);
connection.sendStanza(unexpectedRequest);
return;
}
@ -467,7 +467,7 @@ public class InBandBytestreamSession implements BytestreamSession {
// data is invalid; respond with bad-request error
IQ badRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
XMPPError.Condition.bad_request));
connection.sendPacket(badRequest);
connection.sendStanza(badRequest);
return;
}
@ -476,7 +476,7 @@ public class InBandBytestreamSession implements BytestreamSession {
// confirm IQ
IQ confirmData = IQ.createResultIQ((IQ) packet);
connection.sendPacket(confirmData);
connection.sendStanza(confirmData);
// set last seen sequence
this.lastSequence = data.getSeq();
@ -808,7 +808,7 @@ public class InBandBytestreamSession implements BytestreamSession {
Message message = new Message(remoteJID);
message.addExtension(data);
connection.sendPacket(message);
connection.sendStanza(message);
}

View file

@ -704,7 +704,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
protected void replyRejectPacket(IQ packet) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
this.connection.sendPacket(errorIQ);
this.connection.sendStanza(errorIQ);
}
/**

View file

@ -257,7 +257,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
// send used-host confirmation
Bytestream response = createUsedHostResponse(selectedHost);
this.manager.getConnection().sendPacket(response);
this.manager.getConnection().sendStanza(response);
return new Socks5BytestreamSession(socket, selectedHost.getJID().equals(
this.bytestreamRequest.getFrom()));
@ -282,7 +282,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
String errorMessage = "Could not establish socket with any provided host";
XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
this.manager.getConnection().sendPacket(errorIQ);
this.manager.getConnection().sendStanza(errorIQ);
throw new XMPPErrorException(errorMessage, error);
}

View file

@ -505,7 +505,7 @@ public class EntityCapsManager extends Manager {
if (connection != null && connection.isAuthenticated() && presenceSend) {
Presence presence = new Presence(Presence.Type.available);
try {
connection.sendPacket(presence);
connection.sendStanza(presence);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e);

View file

@ -173,6 +173,6 @@ public class FileTransferManager extends Manager {
// Socks5BytestreamManager.replyRejectPacket(IQ).
IQ rejection = IQ.createErrorResponse(initiation, new XMPPError(
XMPPError.Condition.forbidden));
connection().sendPacket(rejection);
connection().sendStanza(rejection);
}
}

View file

@ -192,7 +192,7 @@ public class FileTransferNegotiator extends Manager {
String errorMessage = "No stream methods contained in stanza.";
XMPPError error = XMPPError.from(XMPPError.Condition.bad_request, errorMessage);
IQ iqPacket = IQ.createErrorResponse(si, error);
connection().sendPacket(iqPacket);
connection().sendStanza(iqPacket);
throw new FileTransferException.NoStreamMethodsOfferedException();
}
@ -203,7 +203,7 @@ public class FileTransferNegotiator extends Manager {
}
catch (NoAcceptableTransferMechanisms e) {
IQ iqPacket = IQ.createErrorResponse(si, XMPPError.from(XMPPError.Condition.bad_request, "No acceptable transfer mechanism"));
connection().sendPacket(iqPacket);
connection().sendStanza(iqPacket);
throw e;
}

View file

@ -98,7 +98,7 @@ public abstract class StreamNegotiator {
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback<NotConnectedException>() {
@Override
public void action() throws NotConnectedException {
connection.sendPacket(response);
connection.sendStanza(response);
}
});
}

View file

@ -518,7 +518,7 @@ public class MultiUserChat {
// field is in the form "roomName@service/nickname"
Presence leavePresence = new Presence(Presence.Type.unavailable);
leavePresence.setTo(room + "/" + nickname);
connection.sendPacket(leavePresence);
connection.sendStanza(leavePresence);
// Reset occupant information.
occupantsMap.clear();
nickname = null;
@ -689,7 +689,7 @@ public class MultiUserChat {
// Add the MUCUser packet that includes the invitation to the message
message.addExtension(mucUser);
connection.sendPacket(message);
connection.sendStanza(message);
}
/**
@ -892,7 +892,7 @@ public class MultiUserChat {
joinPresence.setTo(room + "/" + nickname);
// Send join packet.
connection.sendPacket(joinPresence);
connection.sendStanza(joinPresence);
}
/**
@ -939,7 +939,7 @@ public class MultiUserChat {
form.addField(requestVoiceField);
Message message = new Message(room);
message.addExtension(form);
connection.sendPacket(message);
connection.sendStanza(message);
}
/**
@ -1575,7 +1575,7 @@ public class MultiUserChat {
public void sendMessage(String text) throws XMPPException, NotConnectedException {
Message message = createMessage();
message.setBody(text);
connection.sendPacket(message);
connection.sendStanza(message);
}
/**
@ -1612,7 +1612,7 @@ public class MultiUserChat {
public void sendMessage(Message message) throws XMPPException, NotConnectedException {
message.setTo(room);
message.setType(Message.Type.groupchat);
connection.sendPacket(message);
connection.sendStanza(message);
}
/**

View file

@ -284,7 +284,7 @@ public class MultiUserChatManager extends Manager {
// Add the MUCUser packet that includes the rejection
message.addExtension(mucUser);
connection().sendPacket(message);
connection().sendStanza(message);
}
/**

View file

@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
* Message message = new Message("user@chat.example.com");
* message.setBody("Join me for a group chat!");
* message.addExtension(new GroupChatInvitation("room@chat.example.com"););
* con.sendPacket(message);
* con.sendStanza(message);
* </pre>
*
* To listen for group chat invitations, use a StanzaExtensionFilter for the

View file

@ -115,7 +115,7 @@ public class PEPManager {
//pubSub.setFrom(connection.getUser());
// Send the message that contains the roster
connection.sendPacket(pubSub);
connection.sendStanza(pubSub);
}
/**

View file

@ -211,7 +211,7 @@ public class LeafNode extends Node
{
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.sendPacket(packet);
con.sendStanza(packet);
}
/**
@ -256,7 +256,7 @@ public class LeafNode extends Node
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.sendPacket(packet);
con.sendStanza(packet);
}
/**

View file

@ -56,7 +56,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
* });
* Message message =
* DeliveryReceiptRequest.addTo(message);
* connection.sendPacket(message);
* connection.sendStanza(message);
* </pre>
*
* DeliveryReceiptManager can be configured to automatically add delivery receipt requests to every
@ -158,7 +158,7 @@ public class DeliveryReceiptManager extends Manager {
final Message messageWithReceiptRequest = (Message) packet;
Message ack = receiptMessageFor(messageWithReceiptRequest);
connection.sendPacket(ack);
connection.sendStanza(ack);
}
}, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST);
}

View file

@ -68,7 +68,7 @@ public class CloseListenerTest {
// capture reply to the In-Band Bytestream close request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());

View file

@ -70,7 +70,7 @@ public class DataListenerTest {
// capture reply to the In-Band Bytestream close request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());

View file

@ -78,7 +78,7 @@ public class InBandBytestreamRequestTest {
// capture reply to the In-Band Bytestream open request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());
@ -103,7 +103,7 @@ public class InBandBytestreamRequestTest {
// capture reply to the In-Band Bytestream open request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct acknowledgment packet
assertEquals(initiatorJID, argument.getValue().getTo());

View file

@ -86,7 +86,7 @@ public class InitiationListenerTest {
// capture reply to the In-Band Bytestream open request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());
@ -114,7 +114,7 @@ public class InitiationListenerTest {
// capture reply to the In-Band Bytestream open request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());
@ -204,7 +204,7 @@ public class InitiationListenerTest {
// capture reply to the In-Band Bytestream open request
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());

View file

@ -93,7 +93,7 @@ public class InitiationListenerTest {
// capture reply to the SOCKS5 Bytestream initiation
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());
@ -183,7 +183,7 @@ public class InitiationListenerTest {
// capture reply to the SOCKS5 Bytestream initiation
ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
verify(connection).sendPacket(argument.capture());
verify(connection).sendStanza(argument.capture());
// assert that reply is the correct error packet
assertEquals(initiatorJID, argument.getValue().getTo());

View file

@ -53,7 +53,7 @@ public class ConnectionUtils {
* <pre>
* <code>
* PacketCollector collector = connection.createPacketCollector(new PacketFilter());
* connection.sendPacket(packet);
* connection.sendStanza(packet);
* Packet reply = collector.nextResult();
* </code>
* </pre>
@ -95,7 +95,7 @@ public class ConnectionUtils {
return null;
}
};
doAnswer(addIncoming).when(connection).sendPacket(isA(Stanza.class));
doAnswer(addIncoming).when(connection).sendStanza(isA(Stanza.class));
// mock receive methods
Answer<Stanza> answer = new Answer<Stanza>() {

View file

@ -52,7 +52,7 @@ import org.jivesoftware.smack.packet.Stanza;
* public void methodToTest() {
* Packet packet = new Packet(); // create an XMPP packet
* PacketCollector collector = connection.createPacketCollector(new StanzaIdFilter());
* connection.sendPacket(packet);
* connection.sendStanza(packet);
* Packet reply = collector.nextResult();
* }
*

View file

@ -362,7 +362,7 @@ public class ChatManager extends Manager{
if (message.getFrom() == null) {
message.setFrom(connection().getUser());
}
connection().sendPacket(message);
connection().sendStanza(message);
}
PacketCollector createPacketCollector(Chat chat) {

View file

@ -483,7 +483,7 @@ public class Roster extends Manager {
// Create a presence subscription packet and send.
Presence presencePacket = new Presence(Presence.Type.subscribe);
presencePacket.setTo(user);
connection.sendPacket(presencePacket);
connection.sendStanza(presencePacket);
}
/**
@ -1242,7 +1242,7 @@ public class Roster extends Manager {
}
if (response != null) {
response.setTo(presence.getFrom());
connection.sendPacket(response);
connection.sendStanza(response);
}
break;
case unsubscribe:
@ -1252,7 +1252,7 @@ public class Roster extends Manager {
// has unsubscribed to our presence.
response = new Presence(Presence.Type.unsubscribed);
response.setTo(presence.getFrom());
connection.sendPacket(response);
connection.sendStanza(response);
}
// Otherwise, in manual mode so ignore.
break;

View file

@ -175,7 +175,7 @@ public class JingleManagerTest extends SmackTestCase {
iqSent.setType(IQ.Type.set);
System.out.println("Sending packet and waiting... ");
getConnection(1).sendPacket(iqSent);
getConnection(1).sendStanza(iqSent);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {

View file

@ -368,7 +368,7 @@ public class JingleMediaTest extends SmackTestCase {
Thread.sleep(20000);
//js0.sendFormattedError(JingleError.UNSUPPORTED_TRANSPORTS);
js0.sendPacket(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS));
js0.sendStanza(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS));
Thread.sleep(20000);

View file

@ -75,7 +75,7 @@ public class JingleProviderTest extends SmackTestCase {
System.out.println("Testing if a Jingle IQ can be sent and received...");
// Send the iq packet with an invalid namespace
getConnection(0).sendPacket(iqSent);
getConnection(0).sendStanza(iqSent);
// Receive the packet
IQ iqReceived = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

View file

@ -325,12 +325,12 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// // If the response is anything other than a RESULT then send it now.
// if ((response != null) && (!response.getType().equals(IQ.Type.result))) {
// getConnection().sendPacket(response);
// getConnection().sendStanza(response);
// }
// Loop through all of the responses and send them.
for (IQ response : responses) {
sendPacket(response);
sendStanza(response);
}
}
@ -397,7 +397,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// Send section
// ----------------------------------------------------------------------------------------------------------
public void sendPacket(IQ iq) throws NotConnectedException {
public void sendStanza(IQ iq) throws NotConnectedException {
if (iq instanceof Jingle) {
@ -405,7 +405,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
} else {
getConnection().sendPacket(iq);
getConnection().sendStanza(iq);
}
}
@ -467,7 +467,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// The the packet.
if ((getConnection() != null) && (getConnection().isConnected()))
getConnection().sendPacket(jout);
getConnection().sendStanza(jout);
}
return jout;
}
@ -483,7 +483,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// updatePacketListener();
//
// // Send the actual packet.
// sendPacket(inJingle);
// sendStanza(inJingle);
//
// // Change to the PENDING state.
// setSessionState(JingleSessionStateEnum.PENDING);
@ -507,7 +507,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
IQ ack = IQ.createResultIQ(iq);
// No! Don't send it. Let it flow to the normal way IQ results get processed and sent.
// getConnection().sendPacket(ack);
// getConnection().sendStanza(ack);
result = ack;
}
}
@ -518,7 +518,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* Send a content info message.
*/
// public synchronized void sendContentInfo(ContentInfo ci) {
// sendPacket(new Jingle(new JingleContentInfo(ci)));
// sendStanza(new Jingle(new JingleContentInfo(ci)));
// }
/*
* (non-Javadoc)
@ -806,7 +806,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendPacket(jout);
sendStanza(jout);
//triggerSessionEstablished();
@ -838,7 +838,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendPacket(jout);
sendStanza(jout);
}
}
}
@ -974,7 +974,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
LOGGER.fine("Terminate " + reason);
Jingle jout = new Jingle(JingleActionEnum.SESSION_TERMINATE);
jout.setType(IQ.Type.set);
sendPacket(jout);
sendStanza(jout);
triggerSessionClosed(reason);
}
@ -1035,7 +1035,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// errorPacket.addExtension(jingleError);
// NO! Let the normal state machinery do all of the sending.
// getConnection().sendPacket(perror);
// getConnection().sendStanza(perror);
LOGGER.severe("Error sent: " + errorPacket.toXML());
}
return errorPacket;
@ -1094,7 +1094,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// Save the session-initiate packet ID, so that we can respond to it.
sessionInitPacketID = jingle.getStanzaId();
sendPacket(jingle);
sendStanza(jingle);
// Now setup to track the media negotiators, so that we know when (if) to send a session-accept.
setupListeners();

View file

@ -613,7 +613,7 @@ public abstract class TransportCandidate {
String id = null;
byte[] send = null;
byte[] receive = null;
DatagramPacket sendPacket = null;
DatagramPacket sendStanza = null;
List<DatagramListener> listeners = new ArrayList<DatagramListener>();
List<ResultListener> resultListeners = new ArrayList<ResultListener>();
boolean enabled = true;

View file

@ -82,7 +82,7 @@ public class AgentRoster {
// Send request for roster.
AgentStatusRequest request = new AgentStatusRequest();
request.setTo(workgroupJID);
connection.sendPacket(request);
connection.sendStanza(request);
}
/**
@ -94,7 +94,7 @@ public class AgentRoster {
public void reload() throws NotConnectedException {
AgentStatusRequest request = new AgentStatusRequest();
request.setTo(workgroupJID);
connection.sendPacket(request);
connection.sendStanza(request);
}
/**

View file

@ -318,7 +318,7 @@ public class AgentSession {
presence.setTo(workgroupJID);
presence.addExtension(new DefaultExtensionElement(AgentStatus.ELEMENT_NAME,
AgentStatus.NAMESPACE));
connection.sendPacket(presence);
connection.sendStanza(presence);
}
}
@ -465,7 +465,7 @@ public class AgentSession {
DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID);
// PENDING
this.connection.sendPacket(departPacket);
this.connection.sendStanza(departPacket);
}
/**
@ -693,7 +693,7 @@ public class AgentSession {
if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
// Acknowledge the IQ set.
IQ reply = IQ.createResultIQ((IQ) packet);
connection.sendPacket(reply);
connection.sendStanza(reply);
fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet);
}
@ -782,7 +782,7 @@ public class AgentSession {
else if (packet instanceof OfferRevokeProvider.OfferRevokePacket) {
// Acknowledge the IQ set.
IQ reply = IQ.createResultIQ((OfferRevokeProvider.OfferRevokePacket) packet);
connection.sendPacket(reply);
connection.sendStanza(reply);
fireOfferRevokeEvent((OfferRevokeProvider.OfferRevokePacket)packet);
}

View file

@ -84,7 +84,7 @@ public class Offer {
*/
public void accept() throws NotConnectedException {
Stanza acceptPacket = new AcceptPacket(this.session.getWorkgroupJID());
connection.sendPacket(acceptPacket);
connection.sendStanza(acceptPacket);
// TODO: listen for a reply.
accepted = true;
}
@ -95,7 +95,7 @@ public class Offer {
*/
public void reject() throws NotConnectedException {
RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID());
connection.sendPacket(rejectPacket);
connection.sendStanza(rejectPacket);
// TODO: listen for a reply.
rejected = true;
}

View file

@ -55,7 +55,7 @@ public class OfferConfirmation extends SimpleIQ {
public void notifyService(XMPPConnection con, String workgroup, String createdRoomName) throws NotConnectedException {
NotifyServicePacket packet = new NotifyServicePacket(workgroup, createdRoomName);
con.sendPacket(packet);
con.sendStanza(packet);
}
public static class Provider extends IQProvider<OfferConfirmation> {

View file

@ -218,7 +218,7 @@ public class MessageEventManager extends Manager {
messageEvent.setStanzaId(packetID);
msg.addExtension(messageEvent);
// Send the packet
connection().sendPacket(msg);
connection().sendStanza(msg);
}
/**
@ -237,7 +237,7 @@ public class MessageEventManager extends Manager {
messageEvent.setStanzaId(packetID);
msg.addExtension(messageEvent);
// Send the packet
connection().sendPacket(msg);
connection().sendStanza(msg);
}
/**
@ -256,7 +256,7 @@ public class MessageEventManager extends Manager {
messageEvent.setStanzaId(packetID);
msg.addExtension(messageEvent);
// Send the packet
connection().sendPacket(msg);
connection().sendStanza(msg);
}
/**
@ -275,6 +275,6 @@ public class MessageEventManager extends Manager {
messageEvent.setStanzaId(packetID);
msg.addExtension(messageEvent);
// Send the packet
connection().sendPacket(msg);
connection().sendStanza(msg);
}
}

View file

@ -125,7 +125,7 @@ public class RosterExchangeManager {
XMPPConnection connection = weakRefConnection.get();
// Send the message that contains the roster
connection.sendPacket(msg);
connection.sendStanza(msg);
}
/**
@ -145,7 +145,7 @@ public class RosterExchangeManager {
XMPPConnection connection = weakRefConnection.get();
// Send the message that contains the roster
connection.sendPacket(msg);
connection.sendStanza(msg);
}
/**
@ -168,7 +168,7 @@ public class RosterExchangeManager {
XMPPConnection connection = weakRefConnection.get();
// Send the message that contains the roster
connection.sendPacket(msg);
connection.sendStanza(msg);
}
/**

View file

@ -421,7 +421,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
}
// (Re-)send the stanzas *after* we tried to enable SM
for (Stanza stanza : previouslyUnackedStanzas) {
sendPacketInternal(stanza);
sendStanzaInternal(stanza);
}
afterSuccessfulLogin(false);
@ -508,7 +508,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
setWasAuthenticated();
// If we are able to resume the stream, then don't set
// connected/authenticated/usingTLS to false since we like behave like we are still
// connected (e.g. sendPacket should not throw a NotConnectedException).
// connected (e.g. sendStanza should not throw a NotConnectedException).
if (isSmResumptionPossible() && instant) {
disconnectedButResumeable = true;
} else {
@ -536,7 +536,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
}
@Override
protected void sendPacketInternal(Stanza packet) throws NotConnectedException {
protected void sendStanzaInternal(Stanza packet) throws NotConnectedException {
packetWriter.sendStreamElement(packet);
if (isSmEnabled()) {
for (StanzaFilter requestAckPredicate : requestAckPredicates) {
@ -1342,8 +1342,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
unacknowledgedStanzas = new ArrayBlockingQueue<>(QUEUE_SIZE);
}
// Check if the stream element should be put to the unacknowledgedStanza
// queue. Note that we can not do the put() in sendPacketInternal() and the
// packet order is not stable at this point (sendPacketInternal() can be
// queue. Note that we can not do the put() in sendStanzaInternal() and the
// packet order is not stable at this point (sendStanzaInternal() can be
// called concurrently).
if (unacknowledgedStanzas != null && packet != null) {
// If the unacknowledgedStanza queue is nearly full, request an new ack

View file

@ -35,7 +35,7 @@ public class PacketWriterTest {
/**
* Make sure that packet writer does block once the queue reaches
* {@link PacketWriter#QUEUE_SIZE} and that
* {@link PacketWriter#sendPacket(org.jivesoftware.smack.tcp.packet.Packet)} does unblock after the
* {@link PacketWriter#sendStanza(org.jivesoftware.smack.tcp.packet.Packet)} does unblock after the
* interrupt.
*
* @throws InterruptedException
@ -84,7 +84,7 @@ public class PacketWriterTest {
// will block before we call shutdown. Otherwise we may get false positives (which is still
// better then false negatives).
barrier.await();
// Not really cool, but may increases the chances for 't' to block in sendPacket.
// Not really cool, but may increases the chances for 't' to block in sendStanza.
Thread.sleep(250);
// Set to true for testing purposes, so that shutdown() won't wait packet writer