Closed MOPineyro closed 3 years ago
I just found this error as well. I don't think leaving a channel works at all currently. This is the leave() function in its entirety:
Push leave({Duration timeout}) {
_joinPush?.cancelTimeout();
_rejoinTimer?.cancel();
_state = PhoenixChannelState.leaving;
final leavePush = Push(
this,
event: PhoenixChannelEvent.leave,
payload: () => {},
timeout: timeout,
);
final __onClose = _onClose;
leavePush..onReply('ok', __onClose)..onReply('timeout', __onClose);
if (!socket.isConnected || !isJoined) {
leavePush.trigger(PushResponse(status: 'ok'));
} else {
leavePush.send().then((value) => close());
}
return leavePush;
}
You can see it changes _state = PhoenixChannelState.leaving;
and then below that does a check for !isJoined
. That's just a getter that does this:
bool get isJoined => _state == PhoenixChannelState.joined;
isJoined
will always be false because the state was changed to leaving
. It just immediately returns as an 'ok'.
Another place this same sort of issue is encountered is in the triggerError
method of the same class:
_state = PhoenixChannelState.errored;
if (isJoining) {
_joinPush.reset();
}
Thanks for reporting this, should be fixed really soon.
Fix is part of the 0.4.9 just released version
When calling leave on the phoenix channel I notice that I'm still receiving data. On subsequently attempting to rejoin I'm faced with the !joinOnce error.
Here's a basic implementation:
Any guidance as to how to properly dispose of channel subscriptions would be appreciated.