Parsers¶
MessagePack Parser¶
By default the SocketManager uses a JSon parser and LitJson to encode/decode objects. It's also capable to send and receive MsgPack encoded messages if the server uses socket.io-msgpack-parser.
To enable and use it, follow these steps:
- Download and import the Json & MessagePack Serialization package
- Create a new Asembly Definition file under the Plugins\GameDevWare.Serialization folder
- Locate the
com.tivadar.best.socketio.asmdef
file under thecom.tivadar.best.socketio\Runtime\
folder Reference the newly create asmdef file and press Apply:
Add the BEST_SOCKETIO_ENABLE_GAMEDEVWARE_MESSAGEPACK define to the Scripting Define Symbols input under PlayerSettings/Other Settings:
Use the now available
MsgPackParser
class:
The MsgPackParser
class can be found in the com.tivadar.best.socketio\Runtime\Parsers\
folder.
JSON.NET from Package¶
When Newtonsoft's JSON .NET For Unity is installed through the Package Manager window (or as a dependency of another package), the Best SocketIO package can detect it and automatically enables the JsonDotNetEncoder
class.
JSON.NET from the Asset Store¶
Another JSon parser using Newtonsoft's JSON .NET For Unity.
Steps to enable it and use it:
- Download and import the Newtonsoft's JSON .NET For Unity package.
Add the BEST_SOCKETIO_ENABLE_NEWTONSOFT_JSON_DOTNET_ENCODER define to the Scripting Define Symbols input under PlayerSettings/Other Settings and press Apply:
Use the now-available
JsonDotNetEncoder
class:
JsonDotNetParser
class can be found in the com.tivadar.best.socketio\Runtime\Parsers\
folder.