private void load() { IsConnected.BindValueChanged(connected => Schedule(() => { if (connected.NewValue) { // get all the users that were previously being watched int[] users = watchedUsers.ToArray(); watchedUsers.Clear(); // resubscribe to watched users. foreach (int userId in users) { WatchUser(userId); } // re-send state in case it wasn't received if (IsPlaying) { // TODO: this is likely sent out of order after a reconnect scenario. needs further consideration. BeginPlayingInternal(currentState); } } else { playingUsers.Clear(); watchedUserStates.Clear(); } }), true); }
private void load() { IsConnected.BindValueChanged(connected => Schedule(() => { if (connected.NewValue) { // get all the users that were previously being watched int[] users = watchingUsers.ToArray(); watchingUsers.Clear(); // resubscribe to watched users. foreach (int userId in users) { WatchUser(userId); } // re-send state in case it wasn't received if (IsPlaying) { BeginPlayingInternal(currentState); } } else { playingUsers.Clear(); playingUserStates.Clear(); } }), true); }
private void load() { IsConnected.BindValueChanged(connected => { // clean up local room state on server disconnect. if (!connected.NewValue && Room != null) { Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important); LeaveRoom(); } }); }
protected StatefulMultiplayerClient() { IsConnected.BindValueChanged(connected => { // clean up local room state on server disconnect. if (!connected.NewValue) { Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important); LeaveRoom().CatchUnobservedExceptions(); } }); }