@@ -52,6 +52,11 @@ public class TwitchClientProxy : ITwitchClientProxy {
5252 /// The callback(s) to invoke when a channel receives a ban message.
5353 /// </summary>
5454 private readonly Dictionary < string , Action < OnUserBannedArgs > ? > _onUserBanReceived = new ( ) ;
55+
56+ /// <summary>
57+ /// The callback(s) to invoke when the twitch chat client is disconnected from twitch chat.
58+ /// </summary>
59+ private Action ? _onDisconnected ;
5560
5661 /// <summary>
5762 /// A timer used to re-connect the Twitch chat client.
@@ -73,6 +78,9 @@ public class TwitchClientProxy : ITwitchClientProxy {
7378 /// </summary>
7479 private WebSocketClient ? _socket ;
7580
81+ /// <summary>
82+ /// The twitch OAuth token to use to connect.
83+ /// </summary>
7684 private string ? _twitchOAuthToken ;
7785
7886 /// <summary>
@@ -227,6 +235,17 @@ public void RemoveBannedCallback(string channel, Action<OnUserBannedArgs> callba
227235 _onUserBanReceived . Remove ( channel ) ;
228236 }
229237 }
238+
239+ /// <inheritdoc />
240+ public void AddDisconnectedCallback ( Action callback ) {
241+ _onDisconnected -= callback ;
242+ _onDisconnected += callback ;
243+ }
244+
245+ /// <inheritdoc />
246+ public void RemoveDisconnectedCallback ( Action callback ) {
247+ _onDisconnected -= callback ;
248+ }
230249
231250 /// <inheritdoc />
232251 public async Task AddRaidCallback ( string channel , Action < OnRaidNotificationArgs > callback ) {
@@ -356,12 +375,7 @@ private Task<bool> Connect() {
356375 _client . OnRaidNotification += TwitchChatClient_OnRaidNotification ;
357376 _client . OnDisconnected += ( sender , args ) => {
358377 LOG . Error ( "Twitch Client Disconnected" ) ;
359- try {
360- _client . Reconnect ( ) ;
361- }
362- catch ( Exception ex ) {
363- LOG . Error ( "Twitch Client Reconnect Error" , ex ) ;
364- }
378+ _onDisconnected ? . Invoke ( ) ;
365379 } ;
366380 _client . OnConnectionError += ( sender , args ) => {
367381 LOG . Error ( $ "Twitch Client Connection Error: { args . Error . Message } ") ;
0 commit comments