Skip to content

Commit

Permalink
Disallow attempts to use disposed broadcaster
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Sep 21, 2021
1 parent a6967d1 commit eaa8cd5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions osu.Game.Rulesets.Sentakki/IO/GameplayEventBroadcaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class GameplayEventBroadcaster : IDisposable
// In the event that a broadcast fails, we can resend this message once a new connection is established.
private TransmissionData queuedData;

private bool isDisposed;

public GameplayEventBroadcaster()
{
pipeServer = new NamedPipeServerStream("senPipe", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
Expand Down Expand Up @@ -49,6 +51,9 @@ private void waitForConnectionCallBack(IAsyncResult result)

public void Broadcast(TransmissionData packet)
{
if (isDisposed)
throw new ObjectDisposedException(nameof(GameplayEventBroadcaster));

queuedData = packet;
if (!connectionValid()) return;

Expand All @@ -75,6 +80,7 @@ private bool connectionValid()

public void Dispose()
{
isDisposed = true;
pipeServer.Dispose();
}
}
Expand Down

0 comments on commit eaa8cd5

Please sign in to comment.