My scenario is like this.
I created 2 users on simulator for testing.
When I log in the app, my app will connect socket and add channel with topic like this
var topic = "cart:$userId";
var connectedSocket = await _socket!.connect();
if (connectedSocket!.isConnected &&
connectedSocket.channels.containsKey(topic) != true) {
var channel = connectedSocket.addChannel(topic: topic);
if (channel.state != PhoenixChannelState.joined) {
var pushResponse = await channel.join().future;
And then when I add a item to cart using this function
When I switch to another user (app doesn't restart, just lot out and log in with another user),
My channel object is using previous users' channel.
I inspect it using print(channel!.topic);
It shows me cart:1(previous user) instead of cart:2(current user)
But it still uses previous channel with topic.
I know this problem is from my source code not from this package. but I am stuck on this for couple of days.
So Please give me an advice!
My scenario is like this. I created 2 users on simulator for testing. When I log in the app, my app will connect socket and add channel with topic like this
And then when I add a item to cart using this function
It works but
When I switch to another user (app doesn't restart, just lot out and log in with another user), My channel object is using previous users' channel. I inspect it using
print(channel!.topic);
It shows mecart:1(previous user)
instead ofcart:2(current user)
I tried leaving channel when user logs out.
But it still uses previous channel with topic. I know this problem is from my source code not from this package. but I am stuck on this for couple of days. So Please give me an advice!