Skip to content

Commit

Permalink
Adds shutdown method
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxEdwards20 committed Apr 5, 2024
1 parent 9bdaf05 commit f1959ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Client/Menu/GamePlayView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private MenuStateEnum handleSwitchToMainMenu()
try
{
MessageQueueClient.instance.sendMessage(new Shared.Messages.Disconnect());
MessageQueueClient.instance.shutdown();
MessageQueueClient.shutdown();
}
catch (SocketException e)
{
Expand Down
17 changes: 11 additions & 6 deletions src/Client/MessageQueueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ public bool initialize(string address, ushort port)
/// <summary>
/// Gracefully shutdown the network connection and related activities
/// </summary>
public void shutdown()

public static void shutdown()
{
m_keepRunning = false;
m_eventSendMessages.Set();
m_socketServer.Shutdown(SocketShutdown.Both);
m_socketServer.Disconnect(false);
m_socketServer.Close();
if (m_instance != null)
{
m_instance.m_keepRunning = false;
m_instance.m_eventSendMessages.Set();
m_instance.m_socketServer.Shutdown(SocketShutdown.Both);
m_instance.m_socketServer.Disconnect(false);
m_instance.m_socketServer.Close();
m_instance = null;
}
}

/// <summary>
Expand Down

0 comments on commit f1959ea

Please sign in to comment.