Skip to content

Fixed status not reapplying after disconnect.

Mateusz Brawański requested to merge github/fork/Neuheit/ReapplyActivity into master

Created by: Neuheit

Summary

Ensured that the client will have its status reapplied after a WebSocket connection is terminated. This resolves issue #445 (closed).

Details

After recreating the situation described in the issue, I found that the status after reconnecting becomes null again. As it turned out this was due to:

if (Configuration.AutoReconnect)
{
      DebugLogger.LogMessage(LogLevel.Critical, "Websocket", $"Socket connection terminated ({e.CloseCode.ToString(CultureInfo.InvariantCulture)}, '{e.CloseMessage}'). Reconnecting.", DateTime.Now);
      await ConnectAsync().ConfigureAwait(false);
}

With the arguments not being specified for ConnectAsync(), it is assigned to null in the method body. I fixed this by simply specifying the cached status arguments for ConnectAsync().

Changes proposed

  • Specified the status arguments for the instances of ConnectAsync.
  • Added a new property of type DiscordActivity in StatusUpdate to keep track of the specified Activity.
  • Other grammar corrections I made.

Notes

The majority of lines changed were due to weird space formatting for some reason.

Merge request reports

Loading