Задумка с отрицательным айдишником сработала глобально и кажется она работоспособна
This commit is contained in:
@@ -87,7 +87,7 @@ namespace mROA.Implementation.Backend
|
||||
interaction.PostMessage(new NetworkMessage
|
||||
{
|
||||
Id = Guid.NewGuid(), SchemaId = MessageType.IdAssigning,
|
||||
Data = _serialization.Serialize(new IdAssingnment { Id = interaction.ConnectionId })
|
||||
Data = _serialization.Serialize(new IdAssignment { Id = -interaction.ConnectionId })
|
||||
});
|
||||
_hub.RegisterInteraction(interaction);
|
||||
Console.WriteLine("Client registered");
|
||||
|
||||
@@ -7,18 +7,19 @@ namespace mROA.Implementation
|
||||
{
|
||||
public int ContextId;
|
||||
public int OwnerId;
|
||||
|
||||
public ComplexObjectIdentifier(int contextId, int ownerId)
|
||||
{
|
||||
ContextId = contextId;
|
||||
OwnerId = ownerId;
|
||||
}
|
||||
|
||||
public static ComplexObjectIdentifier Singleton(int ownerId) => new() { ContextId = -1, OwnerId = ownerId };
|
||||
|
||||
public static ComplexObjectIdentifier Null = new ComplexObjectIdentifier { ContextId = -2, OwnerId = -1 };
|
||||
public static ComplexObjectIdentifier Null = new ComplexObjectIdentifier { ContextId = -2, OwnerId = 0 };
|
||||
public static ComplexObjectIdentifier FromFlat(ulong flat) => new() { Flat = flat };
|
||||
|
||||
public int ClientId => Math.Abs(OwnerId);
|
||||
public bool IsSererStored => OwnerId > 0;
|
||||
public bool IsClientStored => OwnerId < 0;
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ {nameof(ContextId)}: {ContextId}, {nameof(OwnerId)}: {OwnerId} }}";
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mROA.Implementation.Frontend
|
||||
}
|
||||
|
||||
|
||||
var assignment = _serialization.Deserialize<IdAssingnment>(welcomeMessage.Data)!;
|
||||
var assignment = _serialization.Deserialize<IdAssignment>(welcomeMessage.Data)!;
|
||||
TransmissionConfig.OwnershipRepository = new StaticOwnershipRepository(assignment.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
public class IdAssingnment
|
||||
public class IdAssignment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace mROA.Implementation
|
||||
}
|
||||
else
|
||||
{
|
||||
_identifier.OwnerId = EndPointContext.HostId;
|
||||
_identifier.OwnerId = EndPointContext.OwnerId;
|
||||
_identifier.ContextId = EndPointContext.RealRepository.GetObjectIndex<T>(Value, EndPointContext);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace mROA.Implementation
|
||||
{
|
||||
get
|
||||
{
|
||||
_identifier.OwnerId = _identifier.OwnerId == -1 ? EndPointContext.OwnerId : _identifier.OwnerId;
|
||||
_identifier.OwnerId = _identifier.OwnerId == 0 ? EndPointContext.OwnerId : _identifier.OwnerId;
|
||||
return _identifier;
|
||||
}
|
||||
set
|
||||
|
||||
Reference in New Issue
Block a user