mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 04:22:05 +01:00
Assert that a Stanza is a Stanza in sendStanza
This commit is contained in:
parent
58402c5615
commit
4a857fe67a
1 changed files with 10 additions and 8 deletions
|
@ -62,6 +62,7 @@ import org.jivesoftware.smack.packet.Bind;
|
||||||
import org.jivesoftware.smack.packet.ErrorIQ;
|
import org.jivesoftware.smack.packet.ErrorIQ;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Mechanisms;
|
import org.jivesoftware.smack.packet.Mechanisms;
|
||||||
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
|
@ -622,25 +623,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendStanza(Stanza packet) throws NotConnectedException, InterruptedException {
|
public void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException {
|
||||||
Objects.requireNonNull(packet, "Packet must not be null");
|
Objects.requireNonNull(stanza, "Stanza must not be null");
|
||||||
|
assert(stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ);
|
||||||
|
|
||||||
throwNotConnectedExceptionIfAppropriate();
|
throwNotConnectedExceptionIfAppropriate();
|
||||||
switch (fromMode) {
|
switch (fromMode) {
|
||||||
case OMITTED:
|
case OMITTED:
|
||||||
packet.setFrom((Jid) null);
|
stanza.setFrom((Jid) null);
|
||||||
break;
|
break;
|
||||||
case USER:
|
case USER:
|
||||||
packet.setFrom(getUser());
|
stanza.setFrom(getUser());
|
||||||
break;
|
break;
|
||||||
case UNCHANGED:
|
case UNCHANGED:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Invoke interceptors for the new packet that is about to be sent. Interceptors may modify
|
// Invoke interceptors for the new stanza that is about to be sent. Interceptors may modify
|
||||||
// the content of the packet.
|
// the content of the stanza.
|
||||||
firePacketInterceptors(packet);
|
firePacketInterceptors(stanza);
|
||||||
sendStanzaInternal(packet);
|
sendStanzaInternal(stanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue