Esempio n. 1
0
 public unsafe void OnMessage(InternedBlobRef senderConnectionString, ReadOnlySpan <byte> message)
 {
     fixed(byte *bytes = message)
     {
         NetworkListener_OnMessage(cppListener, senderConnectionString.handle, bytes, message.Length);
     }
 }
Esempio n. 2
0
        bool TryUpdateObject(StateSnapshot snapshot, UpdatedKey updatedKey)
        {
            InternedBlobRef key  = updatedKey.Key;
            Guid?           guid = ParseObjectKey(key);

            if (guid == null)
            {
                return(false);
            }
            SomeObject obj;

            if (!_objects.TryGetValue(guid.Value, out obj))
            {
                return(false);
            }

            foreach (ulong subkey in updatedKey.InsertedSubkeys)
            {
                obj.UpdateData(snapshot.TryGetValue(key, subkey));
            }

            foreach (ulong subkey in updatedKey.UpdatedSubkeys)
            {
                obj.UpdateData(snapshot.TryGetValue(key, subkey));
            }

            foreach (ulong subkey in updatedKey.RemovedSubkeys)
            {
                obj.UpdateData(new SubkeySnapshot());
            }

            return(true);
        }
Esempio n. 3
0
        Guid?ParseObjectKey(InternedBlobRef key)
        {
            ReadOnlySpan <byte> keySpan = key.ToSpan();

            if (keySpan.Length == ObjectKeySize || keySpan[0] == ObjectKeyPrefix)
            {
                return(new Guid(keySpan.Slice(1)));
            }
            return(null);
        }
Esempio n. 4
0
        bool TryRemoveObject(InternedBlobRef key)
        {
            Guid?guid = ParseObjectKey(key);

            return(guid.HasValue && _objects.Remove(guid.Value));
        }