doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
721 stars 124 forks source link

Using serializer for reading the input stream too, SocketIO becomes generic #323

Closed rahul-mitra closed 1 year ago

rahul-mitra commented 1 year ago

Issue with current version

When the JSON with depth more than default depth of 64 was being received it was throwing error "MaxDepth of 64 has been exceeded" even though while passing custom Newtonsoft.Json Serializer with max depth set to 512 (or anything greater than 64)

Cause

The custom serializer being passed after SocketIO class initialization was not being utilized to read the incoming data, it was used to emit mostly.

Fix

Added functions to IJsonSerializer and implemented in NewtonsoftJsonSerializer and SystemTextJsonSerializer so that even while reading from incoming data serializer is being used, SocketIO class had to made generic, but there is a non generic SocketIO class too which uses JsonElement as type and SystemTextJsonSerializer as default serializer.

doghappy commented 1 year ago

Thanks for your PR. I have refactored a lot of code in the last few months, so we got a lot of conflicts, and I think it already allows you to change the depth.