@@ -52,6 +52,11 @@ public class TwitchClientProxy : ITwitchClientProxy {
52
52
/// The callback(s) to invoke when a channel receives a ban message.
53
53
/// </summary>
54
54
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 ;
55
60
56
61
/// <summary>
57
62
/// A timer used to re-connect the Twitch chat client.
@@ -73,6 +78,9 @@ public class TwitchClientProxy : ITwitchClientProxy {
73
78
/// </summary>
74
79
private WebSocketClient ? _socket ;
75
80
81
+ /// <summary>
82
+ /// The twitch OAuth token to use to connect.
83
+ /// </summary>
76
84
private string ? _twitchOAuthToken ;
77
85
78
86
/// <summary>
@@ -227,6 +235,17 @@ public void RemoveBannedCallback(string channel, Action<OnUserBannedArgs> callba
227
235
_onUserBanReceived . Remove ( channel ) ;
228
236
}
229
237
}
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
+ }
230
249
231
250
/// <inheritdoc />
232
251
public async Task AddRaidCallback ( string channel , Action < OnRaidNotificationArgs > callback ) {
@@ -356,12 +375,7 @@ private Task<bool> Connect() {
356
375
_client . OnRaidNotification += TwitchChatClient_OnRaidNotification ;
357
376
_client . OnDisconnected += ( sender , args ) => {
358
377
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 ( ) ;
365
379
} ;
366
380
_client . OnConnectionError += ( sender , args ) => {
367
381
LOG . Error ( $ "Twitch Client Connection Error: { args . Error . Message } ") ;
0 commit comments