Search code examples
chromecastgoogle-cast

Disconnecting & reconnecting clients to the Receiver Session


I have multiple senders connecting to my receiver simultaneously via Chrome. When one of the senders disconnects (closes browser window, refreshes the page, loses connection... etc) I want the "onSenderDisconnected" event to fire on the receiver.

So far, this only seems to happen when connection is lost for whatever reason. If the sender simply refreshes, for example, the sender is never dropped and a new sender is created. That means I might have 2 senders "connected" from the same source.

Is there any way I can either drop the old sender when one reconnects or is there a way to keep the same senderID on reconnect?

I also want to give each sender the option of disconnecting from the session manually (with a button). The only way to do this currently is to stop casting to the device, but that ends the session for all users. How might I go about this?


Solution

  • For the first item (i.e. adding more senders upon each reload), I have opened an internal issue to investigate that. For the second one, currently you cannot just disconnect your chrome sender without stopping the application; you can either (a) Stop application + disconnect (if you use the cast extension) or (b) close the tab which is like "nothing has happened". We are considering bringing that closer to the APIs on the other two platforms.