public virtual RegisterResponseInfo Register(Guid clientId, string meshId, PeerNodeAddress address)
        {
            Guid              registrationId = Guid.NewGuid();
            DateTime          expires        = DateTime.UtcNow + this.RefreshInterval;
            RegistrationEntry entry          = null;
            MeshEntry         meshEntry      = null;

            lock (this.ThisLock)
            {
                entry     = new RegistrationEntry(clientId, registrationId, meshId, expires, address);
                meshEntry = this.GetMeshEntry(meshId);
                if (meshEntry.Service2EntryTable.ContainsKey(address.ServicePath))
                {
                    PeerExceptionHelper.ThrowInvalidOperation_DuplicatePeerRegistration(address.ServicePath);
                }
                LiteLock liteLock = null;
                try
                {
                    LiteLock.Acquire(out liteLock, meshEntry.Gate, true);
                    meshEntry.EntryTable.Add(registrationId, entry);
                    meshEntry.EntryList.Add(entry);
                    meshEntry.Service2EntryTable.Add(address.ServicePath, entry);
                }
                finally
                {
                    LiteLock.Release(liteLock);
                }
            }
            return(new RegisterResponseInfo(registrationId, this.RefreshInterval));
        }
        public virtual RegisterResponseInfo Register(Guid clientId, string meshId, PeerNodeAddress address)
        {
            Guid     registrationId = Guid.NewGuid();
            DateTime expiry         = DateTime.UtcNow + RefreshInterval;

            RegistrationEntry entry     = null;
            MeshEntry         meshEntry = null;

            lock (ThisLock)
            {
                entry     = new RegistrationEntry(clientId, registrationId, meshId, expiry, address);
                meshEntry = GetMeshEntry(meshId);
                if (meshEntry.Service2EntryTable.ContainsKey(address.ServicePath))
                {
                    PeerExceptionHelper.ThrowInvalidOperation_DuplicatePeerRegistration(address.ServicePath);
                }
                LiteLock ll = null;

                try
                {
                    // meshEntry.gate can be held by this thread for write if this is coming from update
                    // else MUST not be held at all.
                    if (!meshEntry.Gate.IsWriterLockHeld)
                    {
                        LiteLock.Acquire(out ll, meshEntry.Gate, true);
                    }
                    meshEntry.EntryTable.Add(registrationId, entry);
                    meshEntry.EntryList.Add(entry);
                    meshEntry.Service2EntryTable.Add(address.ServicePath, entry);
                }
                finally
                {
                    if (ll != null)
                    {
                        LiteLock.Release(ll);
                    }
                }
            }
            return(new RegisterResponseInfo(registrationId, RefreshInterval));
        }