Skip to content

Commit ce90e1e

Browse files
authored
chore: Handle ephys link disconnect (#663)
* Reset UI on no failed connection * Ignore Ephys Link externally closing for now
1 parent 2b8101b commit ce90e1e

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ void ConnectToServer()
216216
{
217217
_connectionErrorText.text = err;
218218
_connectButtonText.text = "Connect";
219+
220+
_manipulatorTypeDropdown.interactable = !CommunicationManager.Instance.IsConnected;
221+
_launchEphysLinkButton.interactable = !CommunicationManager.Instance.IsConnected;
219222
}
220223
else
221224
{
@@ -260,24 +263,7 @@ public void OnConnectDisconnectPressed()
260263
else
261264
{
262265
// Disconnect from server
263-
QuestionDialogue.Instance.YesCallback = () =>
264-
{
265-
foreach (var probeManager in ProbeManager.Instances
266-
.Where(probeManager => probeManager.IsEphysLinkControlled))
267-
{
268-
probeManager.SetIsEphysLinkControlled(false,
269-
probeManager.ManipulatorBehaviorController.ManipulatorID);
270-
271-
// FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup.
272-
probeManager.ManipulatorBehaviorController.Deinitialize();
273-
}
274-
275-
CommunicationManager.Instance.DisconnectFromServer(() =>
276-
{
277-
KillEphysLinkProcess();
278-
UpdateConnectionPanel();
279-
});
280-
};
266+
QuestionDialogue.Instance.YesCallback = HandleDisconnectingFromServer;
281267

282268
QuestionDialogue.Instance.NewQuestion(
283269
"Are you sure you want to disconnect?\nAll incomplete movements will be canceled.");
@@ -325,6 +311,25 @@ private void HandleSuccessfulConnection()
325311
});
326312
}
327313

314+
private void HandleDisconnectingFromServer()
315+
{
316+
foreach (var probeManager in ProbeManager.Instances
317+
.Where(probeManager => probeManager.IsEphysLinkControlled))
318+
{
319+
probeManager.SetIsEphysLinkControlled(false,
320+
probeManager.ManipulatorBehaviorController.ManipulatorID);
321+
322+
// FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup.
323+
probeManager.ManipulatorBehaviorController.Deinitialize();
324+
}
325+
326+
CommunicationManager.Instance.DisconnectFromServer(() =>
327+
{
328+
KillEphysLinkProcess();
329+
UpdateConnectionPanel();
330+
});
331+
}
332+
328333
/// <summary>
329334
/// Populate UI elements with current connection settings.
330335
/// </summary>

0 commit comments

Comments
 (0)