mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-09-13 12:43:17 +00:00
UUID
This commit is contained in:
@@ -123,29 +123,29 @@ public static class Codec
|
|||||||
DataDeserializer.ResourceParser8,
|
DataDeserializer.ResourceParser8,
|
||||||
},
|
},
|
||||||
new SyncParser[]{
|
new SyncParser[]{
|
||||||
DataDeserializer.Int16Parser,
|
|
||||||
DataDeserializer.UInt16Parser,
|
DataDeserializer.UInt16Parser,
|
||||||
|
DataDeserializer.Int16Parser,
|
||||||
DataDeserializer.Char16Parser,
|
DataDeserializer.Char16Parser,
|
||||||
DataDeserializer.LocalResourceParser16,
|
DataDeserializer.LocalResourceParser16,
|
||||||
DataDeserializer.ResourceParser16,
|
DataDeserializer.ResourceParser16,
|
||||||
},
|
},
|
||||||
new SyncParser[]{
|
new SyncParser[]{
|
||||||
DataDeserializer.Int32Parser,
|
|
||||||
DataDeserializer.UInt32Parser,
|
DataDeserializer.UInt32Parser,
|
||||||
|
DataDeserializer.Int32Parser,
|
||||||
DataDeserializer.Float32Parser,
|
DataDeserializer.Float32Parser,
|
||||||
DataDeserializer.LocalResourceParser32,
|
DataDeserializer.LocalResourceParser32,
|
||||||
DataDeserializer.ResourceParser32,
|
DataDeserializer.ResourceParser32,
|
||||||
},
|
},
|
||||||
new SyncParser[]{
|
new SyncParser[]{
|
||||||
DataDeserializer.Int64Parser,
|
|
||||||
DataDeserializer.UInt64Parser,
|
DataDeserializer.UInt64Parser,
|
||||||
|
DataDeserializer.Int64Parser,
|
||||||
DataDeserializer.Float64Parser,
|
DataDeserializer.Float64Parser,
|
||||||
DataDeserializer.DateTimeParser,
|
DataDeserializer.DateTimeParser,
|
||||||
},
|
},
|
||||||
new SyncParser[]
|
new SyncParser[]
|
||||||
{
|
{
|
||||||
DataDeserializer.Int128Parser, // int 128
|
|
||||||
DataDeserializer.UInt128Parser, // uint 128
|
DataDeserializer.UInt128Parser, // uint 128
|
||||||
|
DataDeserializer.Int128Parser, // int 128
|
||||||
DataDeserializer.Float128Parser,
|
DataDeserializer.Float128Parser,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -114,10 +114,16 @@ public static class DataSerializer
|
|||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) EnumComposer(object value, DistributedConnection connection)
|
public static (TransmissionTypeIdentifier, byte[]) EnumComposer(object value, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(value.GetType().Name);
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var template = connection.Instance.Warehouse.GetTemplateByType(value.GetType());
|
var warehouse = connection?.Instance?.Warehouse ?? connection?.Server?.Instance?.Warehouse;
|
||||||
|
if (warehouse == null)
|
||||||
|
throw new Exception("Warehouse not set.");
|
||||||
|
|
||||||
|
var template = warehouse.GetTemplateByType(value.GetType());
|
||||||
|
|
||||||
var intVal = Convert.ChangeType(value, (value as Enum).GetTypeCode());
|
var intVal = Convert.ChangeType(value, (value as Enum).GetTypeCode());
|
||||||
|
|
||||||
|
@@ -57,6 +57,23 @@ namespace Esiur.Data
|
|||||||
//e6 = data[offset++];
|
//e6 = data[offset++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public unsafe override int GetHashCode()
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
fixed (byte* p = Data)
|
||||||
|
{
|
||||||
|
ulong u0 = *(ulong*)p;
|
||||||
|
ulong u1 = *(ulong*)(p + 8);
|
||||||
|
|
||||||
|
// simple mixing of two 64-bit halves
|
||||||
|
return ((int)u0 ^ (int)(u0 >> 32)) ^
|
||||||
|
((int)u1 ^ (int)(u1 >> 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public UUID(byte[] data) {
|
public UUID(byte[] data) {
|
||||||
|
|
||||||
if (data.Length != 16)
|
if (data.Length != 16)
|
||||||
@@ -88,6 +105,14 @@ namespace Esiur.Data
|
|||||||
//return $"{a1.ToString("x2")}{a2.ToString("x2")}{a3.ToString("x2")}{a4.ToString("x2")}-{b1.ToString("x2")}{b2.ToString("x2")}-{c1.ToString("x2")}{c2.ToString("x2")}-{d1.ToString("x2")}{d2.ToString("x2")}-{e1.ToString("x2")}{e2.ToString("x2")}{e3.ToString("x2")}{e4.ToString("x2")}{e5.ToString("x2")}{e6.ToString("x2")}";
|
//return $"{a1.ToString("x2")}{a2.ToString("x2")}{a3.ToString("x2")}{a4.ToString("x2")}-{b1.ToString("x2")}{b2.ToString("x2")}-{c1.ToString("x2")}{c2.ToString("x2")}-{d1.ToString("x2")}{d2.ToString("x2")}-{e1.ToString("x2")}{e2.ToString("x2")}{e3.ToString("x2")}{e4.ToString("x2")}{e5.ToString("x2")}{e6.ToString("x2")}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj is UUID b)
|
||||||
|
return Data.SequenceEqual(b.Data);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool operator == (UUID a, UUID b)
|
public static bool operator == (UUID a, UUID b)
|
||||||
{
|
{
|
||||||
return a.Data.SequenceEqual(b.Data);
|
return a.Data.SequenceEqual(b.Data);
|
||||||
|
@@ -764,7 +764,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
|
|
||||||
if (this.Instance == null)
|
if (this.Instance == null)
|
||||||
{
|
{
|
||||||
Instance.Warehouse.Put(Server + "/" + session.AuthorizedAccount.Replace("/", "_"), this)
|
Server.Instance.Warehouse.Put(Server + "/" + session.AuthorizedAccount.Replace("/", "_"), this)
|
||||||
.Then(x =>
|
.Then(x =>
|
||||||
{
|
{
|
||||||
openReply?.Trigger(true);
|
openReply?.Trigger(true);
|
||||||
@@ -896,7 +896,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
|
|
||||||
var dataType = authPacket.DataType.Value;
|
var dataType = authPacket.DataType.Value;
|
||||||
|
|
||||||
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
|
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Server.Instance.Warehouse, dataType);
|
||||||
|
|
||||||
var rt = (Map<byte, object>)parsed;
|
var rt = (Map<byte, object>)parsed;
|
||||||
|
|
||||||
@@ -1232,7 +1232,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
|
|
||||||
if (this.Instance == null)
|
if (this.Instance == null)
|
||||||
{
|
{
|
||||||
Instance.Warehouse.Put(
|
Server.Instance.Warehouse.Put(
|
||||||
Server.Instance.Link + "/" + this.GetHashCode().ToString().Replace("/", "_"), this)
|
Server.Instance.Link + "/" + this.GetHashCode().ToString().Replace("/", "_"), this)
|
||||||
.Then(x =>
|
.Then(x =>
|
||||||
{
|
{
|
||||||
|
@@ -11,6 +11,6 @@ namespace Esiur.Net.Packets
|
|||||||
Email = 2,
|
Email = 2,
|
||||||
SMS = 3,
|
SMS = 3,
|
||||||
App = 4, // Authenticator app
|
App = 4, // Authenticator app
|
||||||
ThirdParty = 5, // usualy a second person
|
ThirdParty = 5, // usually a second person
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,22 +22,23 @@ SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using Esiur.Data;
|
|
||||||
using Esiur.Core;
|
using Esiur.Core;
|
||||||
|
using Esiur.Data;
|
||||||
|
using Esiur.Misc;
|
||||||
|
using Esiur.Net.IIP;
|
||||||
|
using Esiur.Net.Packets;
|
||||||
using Esiur.Proxy;
|
using Esiur.Proxy;
|
||||||
using Esiur.Resource.Template;
|
using Esiur.Resource.Template;
|
||||||
using Esiur.Security.Permissions;
|
using Esiur.Security.Permissions;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Esiur.Net.IIP;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Esiur.Misc;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace Esiur.Resource;
|
namespace Esiur.Resource;
|
||||||
|
|
||||||
@@ -85,6 +86,11 @@ public class Warehouse
|
|||||||
Protocols.Add("iip",
|
Protocols.Add("iip",
|
||||||
async (name, attributes)
|
async (name, attributes)
|
||||||
=> await New<DistributedConnection>(name, null, attributes));
|
=> await New<DistributedConnection>(name, null, attributes));
|
||||||
|
|
||||||
|
new TypeTemplate(typeof(IIPAuthPacketIAuthHeader), this);
|
||||||
|
|
||||||
|
new TypeTemplate(typeof(IIPAuthPacketIAuthDestination), this);
|
||||||
|
new TypeTemplate(typeof(IIPAuthPacketIAuthFormat), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user