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