コード例 #1
0
        public ServerObjectBase ResolveReference(Guid reference)
        {
            lock (Sync)
            {
                if (!_knownDtos.TryGetValue(reference, out var p))
                {
                    return(ServerObjectBase.FindDto(reference));
                }

                return(p);
            }
        }
コード例 #2
0
        public bool RestoreReference(IDto messageDto)
        {
            lock (Sync)
            {
                var dto = ServerObjectBase.FindDto(messageDto.DtoGuid);
                if (dto == null)
                {
                    Logger.Warn("Could not restore Dto (null on server side)! {0}", dto.DtoGuid);
                    return(false);
                }
                if (_knownDtos.ContainsKey(dto.DtoGuid))
                {
                    Logger.Warn("Server already knows about this dto, nothing to restore. {0}", dto.DtoGuid);
                    return(false);
                }
                _knownDtos.Add(dto.DtoGuid, dto);
                Logger.Debug("Object ressurection acknowledged {0}", dto.DtoGuid);
            }

            return(true);
        }
コード例 #3
0
        public object ResolveReference(object context, string reference)
        {
            var id = new Guid(reference);

            lock (Sync)
            {
                if (!_knownDtos.TryGetValue(id, out var value))
                {
                    var dto = ServerObjectBase.FindDto(id);
                    if (dto == null)
                    {
                        return(null);
                    }

                    //_knownDtos[id] = value;
                    //Logger.Warn("Reference not found in knownDtos, but found locally - adding to known. {0}", dto.DtoGuid);
                    return(dto);
                }

                Logger.Trace("ResolveReference {0} with {1}", reference, value);
                return(value);
            }
        }
コード例 #4
0
 public ServerHost(ushort listenPort, ServerObjectBase rootObject, IPrincipalProvider principalProvider = null)
 {
     ListenPort         = listenPort;
     _rootServerObject  = rootObject;
     _principalProvider = principalProvider ?? PrincipalProvider.Default;
 }