May try to track through room.onStateChange, i.e.
create on the server in a state, let's say the variable MyConnect: true when called
room.onStateChange((state) => {
if (state.MyConnect != true) {
// Do something ...
}
});
If the connection is terminated, then state.MyConnect will be undefined, which means it will not equal true