Skip to content

Commit 53c4ef6

Browse files
authored
Fix backwards compatibility with Unity 2019 and 2020 (#156)
1 parent 87bba80 commit 53c4ef6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Assets/Plugins/StreamChat/Libs/Websockets/WebsocketClient.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,19 @@ private async Task TryCloseAndDisposeAsync(WebSocketCloseStatus closeStatus, str
283283
{
284284
try
285285
{
286+
#if UNITY_2021_2_OR_NEWER
286287
if (_backgroundReceiveTimer != null)
287288
{
288289
await _backgroundReceiveTimer.DisposeAsync();
289290
_backgroundReceiveTimer = null;
290291
}
292+
#else
293+
if (_backgroundReceiveTimer != null)
294+
{
295+
_backgroundReceiveTimer.Dispose();
296+
_backgroundReceiveTimer = null;
297+
}
298+
#endif
291299
}
292300
catch (Exception e)
293301
{
@@ -296,11 +304,20 @@ private async Task TryCloseAndDisposeAsync(WebSocketCloseStatus closeStatus, str
296304

297305
try
298306
{
307+
#if UNITY_2021_2_OR_NEWER
299308
if (_backgroundSendTimer != null)
300309
{
301310
await _backgroundSendTimer.DisposeAsync();
302311
_backgroundSendTimer = null;
303312
}
313+
#else
314+
if (_backgroundSendTimer != null)
315+
{
316+
_backgroundSendTimer.Dispose();
317+
_backgroundSendTimer = null;
318+
}
319+
#endif
320+
304321
}
305322
catch (Exception e)
306323
{
@@ -375,7 +392,7 @@ await TryCloseAndDisposeAsync(WebSocketCloseStatus.ProtocolError,
375392
}
376393
catch (Exception e)
377394
{
378-
_logs.Exception(exception);
395+
_logs.Exception(e);
379396
}
380397

381398
var isHandledExceptionType = exception is OperationCanceledException || exception is WebSocketException || exception is SocketException;

0 commit comments

Comments
 (0)