Initial Client/Server Communication
#1 Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
This commit is contained in:
parent
52b0d4d8ff
commit
a0c8dbee72
493 changed files with 57790 additions and 3 deletions
|
|
@ -0,0 +1,81 @@
|
|||
// Copyright (c) All contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using MessagePack.Formatters;
|
||||
|
||||
namespace MessagePack.Resolvers
|
||||
{
|
||||
public sealed class PrimitiveObjectResolver : IFormatterResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton instance that can be used.
|
||||
/// </summary>
|
||||
public static readonly PrimitiveObjectResolver Instance;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="MessagePackSerializerOptions"/> instance with this formatter pre-configured.
|
||||
/// </summary>
|
||||
public static readonly MessagePackSerializerOptions Options;
|
||||
|
||||
static PrimitiveObjectResolver()
|
||||
{
|
||||
Instance = new PrimitiveObjectResolver();
|
||||
Options = new MessagePackSerializerOptions(Instance);
|
||||
}
|
||||
|
||||
private PrimitiveObjectResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return FormatterCache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class FormatterCache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T> Formatter;
|
||||
|
||||
static FormatterCache()
|
||||
{
|
||||
Formatter = (typeof(T) == typeof(object))
|
||||
? (IMessagePackFormatter<T>)(object)PrimitiveObjectFormatter.Instance
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////#if !UNITY_2018_3_OR_NEWER
|
||||
|
||||
//// /// <summary>
|
||||
//// /// In `object`, when serializing resolve by concrete type and when deserializing use primitive.
|
||||
//// /// </summary>
|
||||
//// public sealed class DynamicObjectTypeFallbackResolver : IFormatterResolver
|
||||
//// {
|
||||
//// public static readonly DynamicObjectTypeFallbackResolver Instance = new DynamicObjectTypeFallbackResolver();
|
||||
|
||||
//// DynamicObjectTypeFallbackResolver()
|
||||
//// {
|
||||
|
||||
//// }
|
||||
|
||||
//// public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
//// {
|
||||
//// return FormatterCache<T>.formatter;
|
||||
//// }
|
||||
|
||||
//// static class FormatterCache<T>
|
||||
//// {
|
||||
//// public static readonly IMessagePackFormatter<T> formatter;
|
||||
|
||||
//// static FormatterCache()
|
||||
//// {
|
||||
//// formatter = (typeof(T) == typeof(object))
|
||||
//// ? (IMessagePackFormatter<T>)(object)DynamicObjectTypeFallbackFormatter.Instance
|
||||
//// : null;
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
|
||||
////#endif
|
||||
}
|
||||
Loading…
Reference in a new issue