mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
[core] Get stream-open-like element from transport
When sending a stream-open-like element, it depends on the actual used transport which element is send. For example, RFC6120-style TCP uses <stream>, whereas the Websocket binding for XMPP uses <open/>.
This commit is contained in:
parent
e6a60213b6
commit
f892ba1369
3 changed files with 18 additions and 3 deletions
|
@ -2229,7 +2229,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
protected void sendStreamOpen() throws NotConnectedException, InterruptedException {
|
||||
protected final void sendStreamOpen() throws NotConnectedException, InterruptedException {
|
||||
// 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
|
||||
|
@ -2241,12 +2241,17 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
from = XmppStringUtils.completeJidFrom(localpart, to);
|
||||
}
|
||||
String id = getStreamId();
|
||||
String lang = config.getXmlLang();
|
||||
|
||||
StreamOpen streamOpen = new StreamOpen(to, from, id, config.getXmlLang(), StreamOpen.StreamContentNamespace.client);
|
||||
AbstractStreamOpen streamOpen = getStreamOpen(to, from, id, lang);
|
||||
sendNonza(streamOpen);
|
||||
updateOutgoingStreamXmlEnvironmentOnStreamOpen(streamOpen);
|
||||
}
|
||||
|
||||
protected AbstractStreamOpen getStreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||
return new StreamOpen(to, from, id, lang);
|
||||
}
|
||||
|
||||
protected void updateOutgoingStreamXmlEnvironmentOnStreamOpen(AbstractStreamOpen streamOpen) {
|
||||
XmlEnvironment.Builder xmlEnvironmentBuilder = XmlEnvironment.builder();
|
||||
xmlEnvironmentBuilder.with(streamOpen);
|
||||
|
|
|
@ -560,6 +560,12 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
|||
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractStreamOpen getStreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||
StreamOpenAndCloseFactory streamOpenAndCloseFactory = activeTransport.getStreamOpenAndCloseFactory();
|
||||
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
|
||||
}
|
||||
|
||||
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
|
||||
SmackException, XMPPException {
|
||||
prepareToWaitForFeaturesReceived();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,6 +33,10 @@ public final class StreamOpen extends AbstractStreamOpen {
|
|||
this(to, from, id, "en", StreamContentNamespace.client);
|
||||
}
|
||||
|
||||
public StreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||
super(to, from, id, lang);
|
||||
}
|
||||
|
||||
public StreamOpen(CharSequence to, CharSequence from, String id, String lang, StreamContentNamespace ns) {
|
||||
super(to, from, id, lang, ns);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue