up
This commit is contained in:
25
Assets/BestHTTP/SocketIO/JsonEncoders/DefaultJSonEncoder.cs
Normal file
25
Assets/BestHTTP/SocketIO/JsonEncoders/DefaultJSonEncoder.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
#if !BESTHTTP_DISABLE_SOCKETIO
|
||||
|
||||
using System.Collections.Generic;
|
||||
using BestHTTP.JSON;
|
||||
|
||||
namespace BestHTTP.SocketIO.JsonEncoders
|
||||
{
|
||||
/// <summary>
|
||||
/// The default IJsonEncoder implementation. It's uses the Json class from the BestHTTP.JSON namespace to encode and decode.
|
||||
/// </summary>
|
||||
public sealed class DefaultJSonEncoder : IJsonEncoder
|
||||
{
|
||||
public List<object> Decode(string json)
|
||||
{
|
||||
return Json.Decode(json) as List<object>;
|
||||
}
|
||||
|
||||
public string Encode(List<object> obj)
|
||||
{
|
||||
return Json.Encode(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eab45a006264449979dbfb9f504c1774
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/BestHTTP/SocketIO/JsonEncoders/IJSonEncoder.cs
Normal file
24
Assets/BestHTTP/SocketIO/JsonEncoders/IJSonEncoder.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
#if !BESTHTTP_DISABLE_SOCKETIO
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BestHTTP.SocketIO.JsonEncoders
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to be able to write custom Json encoders/decoders.
|
||||
/// </summary>
|
||||
public interface IJsonEncoder
|
||||
{
|
||||
/// <summary>
|
||||
/// The Decode function must create a list of objects from the Json formatted string parameter. If the decoding fails, it should return null.
|
||||
/// </summary>
|
||||
List<object> Decode(string json);
|
||||
|
||||
/// <summary>
|
||||
/// The Encode function must create a json formatted string from the parameter. If the encoding fails, it should return null.
|
||||
/// </summary>
|
||||
string Encode(List<object> obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SocketIO/JsonEncoders/IJSonEncoder.cs.meta
Normal file
11
Assets/BestHTTP/SocketIO/JsonEncoders/IJSonEncoder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df0af13937a45496698838e13069cc5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user