mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Send more information with the stream open tag
This commit is contained in:
parent
e493500cfe
commit
37081b2810
3 changed files with 35 additions and 5 deletions
|
@ -74,6 +74,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.TLSUtils;
|
||||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -882,7 +883,18 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
* @throws SmackException if the parser could not be reset.
|
||||
*/
|
||||
void openStream() throws SmackException {
|
||||
send(new StreamOpen(getServiceName()));
|
||||
// If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
|
||||
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
|
||||
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
|
||||
// response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
|
||||
CharSequence to = getServiceName();
|
||||
CharSequence from = null;
|
||||
CharSequence localpart = config.getUsername();
|
||||
if (localpart != null) {
|
||||
from = XmppStringUtils.completeJidFrom(localpart, to);
|
||||
}
|
||||
String id = getConnectionID();
|
||||
send(new StreamOpen(to, from, id));
|
||||
try {
|
||||
packetReader.parser = PacketParserUtils.newXmppParser(reader);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue