fix(core): Prevent resource binding if we already have a resource
This commit is contained in:
parent
f460e5ebe9
commit
63b7abd6f9
@ -270,6 +270,7 @@ class XmppConnection {
|
||||
negotiator.register(
|
||||
NegotiatorAttributes(
|
||||
sendRawXML,
|
||||
() => this,
|
||||
() => _connectionSettings,
|
||||
_sendEvent,
|
||||
getNegotiatorById,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:moxlib/moxlib.dart';
|
||||
import 'package:moxxmpp/src/connection.dart';
|
||||
import 'package:moxxmpp/src/errors.dart';
|
||||
import 'package:moxxmpp/src/events.dart';
|
||||
import 'package:moxxmpp/src/jid.dart';
|
||||
@ -28,6 +29,7 @@ abstract class NegotiatorError extends XmppError {}
|
||||
class NegotiatorAttributes {
|
||||
const NegotiatorAttributes(
|
||||
this.sendNonza,
|
||||
this.getConnection,
|
||||
this.getConnectionSettings,
|
||||
this.sendEvent,
|
||||
this.getNegotiatorById,
|
||||
@ -46,7 +48,10 @@ class NegotiatorAttributes {
|
||||
/// Returns the connection settings.
|
||||
final ConnectionSettings Function() getConnectionSettings;
|
||||
|
||||
/// Send an event event to the connection's event bus
|
||||
/// Returns the connection object.
|
||||
final XmppConnection Function() getConnection;
|
||||
|
||||
/// Send an event event to the connection's event bus.
|
||||
final Future<void> Function(XmppEvent event) sendEvent;
|
||||
|
||||
/// Returns the negotiator with id id of the connection or null.
|
||||
|
@ -30,10 +30,13 @@ class ResourceBindingNegotiator extends XmppFeatureNegotiatorBase {
|
||||
if (sm != null) {
|
||||
return super.matchesFeature(features) &&
|
||||
!sm.streamResumed &&
|
||||
attributes.isAuthenticated();
|
||||
attributes.isAuthenticated() &&
|
||||
attributes.getConnection().resource.isEmpty;
|
||||
}
|
||||
|
||||
return super.matchesFeature(features) && attributes.isAuthenticated();
|
||||
return super.matchesFeature(features) &&
|
||||
attributes.isAuthenticated() &&
|
||||
attributes.getConnection().resource.isEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -46,6 +46,11 @@ void main() {
|
||||
)..register(
|
||||
NegotiatorAttributes(
|
||||
(XMLNode _, {String? redact}) {},
|
||||
() => XmppConnection(
|
||||
TestingReconnectionPolicy(),
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
fakeSocket,
|
||||
),
|
||||
() => ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
@ -142,6 +147,11 @@ void main() {
|
||||
)..register(
|
||||
NegotiatorAttributes(
|
||||
(XMLNode n, {String? redact}) => lastMessage = n.innerText(),
|
||||
() => XmppConnection(
|
||||
TestingReconnectionPolicy(),
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
StubTCPSocket([]),
|
||||
),
|
||||
() => ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
@ -193,6 +203,11 @@ void main() {
|
||||
)..register(
|
||||
NegotiatorAttributes(
|
||||
(XMLNode _, {String? redact}) {},
|
||||
() => XmppConnection(
|
||||
TestingReconnectionPolicy(),
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
StubTCPSocket([]),
|
||||
),
|
||||
() => ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
@ -234,6 +249,11 @@ void main() {
|
||||
)..register(
|
||||
NegotiatorAttributes(
|
||||
(XMLNode _, {String? redact}) {},
|
||||
() => XmppConnection(
|
||||
TestingReconnectionPolicy(),
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
StubTCPSocket([]),
|
||||
),
|
||||
() => ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
@ -278,6 +298,11 @@ void main() {
|
||||
)..register(
|
||||
NegotiatorAttributes(
|
||||
(XMLNode _, {String? redact}) {},
|
||||
() => XmppConnection(
|
||||
TestingReconnectionPolicy(),
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
StubTCPSocket([]),
|
||||
),
|
||||
() => ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
|
Loading…
Reference in New Issue
Block a user