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
62
Assets/Scripts/MagicOnion/MetadataExtensions.cs
Normal file
62
Assets/Scripts/MagicOnion/MetadataExtensions.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using Grpc.Core;
|
||||
using System;
|
||||
|
||||
namespace MagicOnion
|
||||
{
|
||||
public static class MetadataExtensions
|
||||
{
|
||||
public const string BinarySuffix = "-bin";
|
||||
|
||||
/// <summary>
|
||||
/// Get metdata entry. If does not exists, return null.
|
||||
/// </summary>
|
||||
public static Metadata.Entry Get(this Metadata metadata, string key, bool ignoreCase = true)
|
||||
{
|
||||
for (int i = 0; i < metadata.Count; i++)
|
||||
{
|
||||
var entry = metadata[i];
|
||||
if (ignoreCase)
|
||||
{
|
||||
if (entry.Key.Equals(key, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.Key == key)
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get metdata string value. If does not exists, return null.
|
||||
/// </summary>
|
||||
public static string GetValue(this Metadata metadata, string key, bool ignoreCase = true)
|
||||
{
|
||||
for (int i = 0; i < metadata.Count; i++)
|
||||
{
|
||||
var entry = metadata[i];
|
||||
if (ignoreCase)
|
||||
{
|
||||
if (entry.Key.Equals(key, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return entry.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.Key == key)
|
||||
{
|
||||
return entry.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue