Skip to content

Commit 30fc6b2

Browse files
committed
protect api
1 parent 80cf3df commit 30fc6b2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/SocketIOClient/SocketIO.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Uri ServerUri
9696

9797
public Func<IClientWebSocket> ClientWebSocketProvider { get; set; }
9898

99-
public List<Type> ExpectedExceptions { get; private set; }
99+
List<Type> _expectedExceptions;
100100

101101
int _packetId;
102102
Dictionary<int, Action<SocketIOResponse>> _ackHandlers;
@@ -153,7 +153,7 @@ private void Initialize()
153153
_connectionTokenSorce = new CancellationTokenSource();
154154
HttpClient = new HttpClient();
155155
ClientWebSocketProvider = () => new DefaultClientWebSocket();
156-
ExpectedExceptions = new List<Type>
156+
_expectedExceptions = new List<Type>
157157
{
158158
typeof(TimeoutException),
159159
typeof(WebSocketException),
@@ -215,7 +215,7 @@ public async Task ConnectAsync()
215215
}
216216
catch (Exception e)
217217
{
218-
if (ExpectedExceptions.Contains(e.GetType()))
218+
if (_expectedExceptions.Contains(e.GetType()))
219219
{
220220
if (!Options.Reconnection)
221221
{
@@ -661,6 +661,14 @@ private async void InvokeDisconnect(string reason)
661661
}
662662
}
663663

664+
public void AddExpectedException(Type type)
665+
{
666+
if (!_expectedExceptions.Contains(type))
667+
{
668+
_expectedExceptions.Add(type);
669+
}
670+
}
671+
664672
public void Dispose()
665673
{
666674
HttpClient.Dispose();

0 commit comments

Comments
 (0)