Пример #1
0
    void Start()
    {
        if (isServer)
        {
            // Instancia o mapa geral que é sincronizado entre todos os players
            List <BlockContent> tmpMapContent = new List <BlockContent>();
            for (int i = 0; i < mapRows * mapCols; i++)
            {
                tmpMapContent.Add(new BlockContent(null, VoxelData.VoxelType.Block, (int)BlockData.BlockEnum.Ground));
            }

            mapContent.AddRange(tmpMapContent);
        }
    }
Пример #2
0
        private void Update()
        {
            if (!isServer)
            {
                return;
            }

            if (IsTargetUpdateNeeded())
            {
                UpdateTargets();
            }

            syncedTargetPositions.Clear();
            syncedTargetPositions.AddRange(targets.Select(x => x.transform.position));
        }
Пример #3
0
        public static void Generate(string computerName, SyncList <DprNetworkInfo> result)
        {
            Helpers.AssertNotNull(result, @"result SyncList cannot be null");
            Helpers.AssertString(computerName, @"Computer name cannot be empty");
            var networkInfoList = new List <DprNetworkInfo>( );

            try {
                WmiHelpers.ForEach(computerName, @"SELECT * FROM Win32_NetworkAdapterConfiguration", obj => {
                    var ci = new DprNetworkInfo(computerName);
                    ci.DefaultIpGateway             = WmiHelpers.GetStringArray(obj, @"DefaultIPGateway");
                    ci.Description                  = WmiHelpers.GetString(obj, @"Description");
                    ci.DhcpEnabled                  = WmiHelpers.GetBoolean(obj, @"DHCPEnabled");
                    ci.DhcpLeaseExpires             = WmiHelpers.GetNullableDate(obj, @"DHCPLeaseExpires", true);
                    ci.DhcpLeaseObtained            = WmiHelpers.GetNullableDate(obj, @"DHCPLeaseObtained", true);
                    ci.DhcpServer                   = WmiHelpers.GetString(obj, @"DHCPServer");
                    ci.DnsDomain                    = WmiHelpers.GetString(obj, @"DNSDomain");
                    ci.DnsDomainSuffixSearchOrder   = WmiHelpers.GetStringArray(obj, @"DNSDomainSuffixSearchOrder");
                    ci.DnsEnabledForWinsResolution  = WmiHelpers.GetNullableBoolean(obj, @"DNSEnabledForWINSResolution");
                    ci.DnsHostName                  = WmiHelpers.GetString(obj, @"DNSHostName");
                    ci.DnsServerSearchOrder         = WmiHelpers.GetStringArray(obj, @"DNSServerSearchOrder");
                    ci.DomainDnsRegistrationEnabled = WmiHelpers.GetNullableBoolean(obj, @"DomainDNSRegistrationEnabled");
                    ci.FullDnsRegistrationEnabled   = WmiHelpers.GetNullableBoolean(obj, @"FullDNSRegistrationEnabled");
                    ci.Index                   = WmiHelpers.GetUInt(obj, @"Index");
                    ci.InterfaceIndex          = WmiHelpers.GetUInt(obj, @"InterfaceIndex");
                    ci.IpAddress               = WmiHelpers.GetStringArray(obj, @"IPAddress");
                    ci.IpConnectionMetric      = WmiHelpers.GetNullableUInt(obj, @"IPConnectionMetric");
                    ci.IpEnabled               = WmiHelpers.GetNullableBoolean(obj, @"IPEnabled");
                    ci.MacAddress              = WmiHelpers.GetString(obj, @"MACAddress");
                    ci.SettingId               = WmiHelpers.GetString(obj, @"SettingID");
                    ci.WinsEnableLmHostsLookup = WmiHelpers.GetNullableBoolean(obj, @"WINSEnableLMHostsLookup");
                    ci.WinsHostLookupFile      = WmiHelpers.GetString(obj, @"WINSHostLookupFile");
                    ci.WinsPrimaryServer       = WmiHelpers.GetString(obj, @"WINSPrimaryServer");
                    ci.WinsSecondaryServer     = WmiHelpers.GetString(obj, @"WINSSecondaryServer");
                    ci.WinsScopeId             = WmiHelpers.GetString(obj, @"WINSScopeID");

                    networkInfoList.Add(ci);
                    return(true);
                }, true, false);
            } catch (UnauthorizedAccessException) {
                result.Add(new DprNetworkInfo(computerName, ConnectionStatuses.AuthorizationError));
                return;
            } catch (Exception) {
                result.Add(new DprNetworkInfo(computerName, ConnectionStatuses.Error));
                return;
            }
            result.AddRange(networkInfoList);
            ValidateUniqueness(result);
        }
Пример #4
0
 public void TestAddRange()
 {
     serverSyncList.AddRange(new[] { "One", "Two", "Three" });
     SerializeDeltaTo(serverSyncList, clientSyncList);
     Assert.That(clientSyncList, Is.EqualTo(new[] { "Hello", "World", "!", "One", "Two", "Three" }));
 }
Пример #5
0
 public void UpdatePlayers()
 {
     PlayerDatas.Clear();
     PlayerDatas.AddRange(TDGameNetworkManager.Instance.connectedPlayers.Values.ToArray());
 }
Пример #6
0
		private static void GetLocallyLoggedOnUsers( string computerName, SyncList.SyncList<DprCurrentUsers> result ) {
			var usersList = new List<DprCurrentUsers>( );
			using( var regHku = RegistryKey.OpenRemoteBaseKey( RegistryHive.Users, string.Empty ) ) {
				foreach( var currentSid in regHku.GetSubKeyNames( ).Where( IsSid ) ) {
					var cu = new DprCurrentUsers( computerName ) { Sid = currentSid };
					try {
						if( Win32.WellKnownSids.ContainsKey( currentSid ) ) {
							cu.Domain = computerName;	// Local account
							cu.UserName = Win32.WellKnownSids[currentSid];
						} else {
							GetUserAccountFromSid( ref cu );
						}
						cu.ProfileFolder = RegistryHelpers.GetString( computerName, RegistryHive.LocalMachine, string.Format( @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{0}", currentSid ), @"ProfileImagePath" );
						cu.LastLogon = GetUsersLogonTimestamp( cu );					
					} catch( Exception ex ) {
						GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", ex.TargetSite, ex.Message );
						cu = new DprCurrentUsers( computerName, ConnectionStatuses.Error ) { Sid = currentSid };
					}
					cu.LogonType = LogonTypes.Local;
					usersList.Add( cu );
				}
			}
			result.AddRange( usersList );
		}
Пример #7
0
		private static Win32.Error GetNetworkUsers( string computerName, ref SyncList.SyncList<DprCurrentUsers> result ) {
			Win32.Error res;
			var er = 0;
			var tr = 0;
			var resume = 0;
			var buffer = IntPtr.Zero;
			var usersList = new List<DprCurrentUsers>( );
			do {
				try {
					res = (Win32.Error)Win32.NetSessionEnum( computerName, null, null, 502, out buffer, -1, ref er, ref tr, ref resume );
					if( res == Win32.Error.ErrorMoreData || res == Win32.Error.Success ) {
						var bufferPtrInt = buffer.ToInt32( );
						for( var i = 0; i < er; i++ ) {
							var sessionInfo = (Win32.SessionInfo502)Marshal.PtrToStructure( new IntPtr( bufferPtrInt ), typeof( Win32.SessionInfo502 ) );
							var cu = new DprCurrentUsers( computerName ) {
								UserName = sessionInfo.userName, LastLogon = DateTime.Now.AddSeconds( -sessionInfo.logonDuration ), LogonType = LogonTypes.Share
							};
							usersList.Add( cu );
							bufferPtrInt += Marshal.SizeOf( typeof( Win32.SessionInfo502 ) );
						}

					} else {
						switch( res ) {
						case Win32.Error.ErrorAccessDenied:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Access Denied: {0}", computerName );
							break;
						case Win32.Error.ErrorNotEnoughMemory:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Not Enough Memory: {0}", computerName );
							break;
						case Win32.Error.ErrorBadNetpath:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Bad Network Path: {0}", computerName );
							break;
						case Win32.Error.ErrorNetworkBusy:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Network Busy: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidParameter:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Parameter: {0}", computerName );
							break;
						case Win32.Error.ErrorInsufficientBuffer:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Insufficient Buff: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidLevel:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Level: {0}", computerName );
							break;
						case Win32.Error.ErrorExtendedError:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Exended Error: {0}", computerName );
							break;
						case Win32.Error.ErrorNoNetwork:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: No Network: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidHandleState:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Handle State: {0}", computerName );
							break;
						case Win32.Error.NerrBase:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: NERR_BASE: {0}", computerName );
							break;
						case Win32.Error.NerrUnknownDevDir:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Unknown Device Directory: {0}", computerName );
							break;
						case Win32.Error.NerrDuplicateShare:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Duplicate Share: {0}", computerName );
							break;
						case Win32.Error.NerrBufTooSmall:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Buffer too small: {0}", computerName );
							break;
						case Win32.Error.ErrorNoBrowserServersFound:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: No Browser Servers Found: {0}", computerName );
							break;
						}
						return res;
					}
				} finally {
					if( IntPtr.Zero != buffer ) {
						Win32.NetApiBufferFree( buffer );
					}
				}
			} while( res == Win32.Error.ErrorMoreData );
			result.AddRange( usersList );
			return Win32.Error.Success;
		}
Пример #8
0
		public static void Generate( string computerName, SyncList<DprNetworkInfo> result ) {
			Helpers.AssertNotNull( result, @"result SyncList cannot be null" );
			Helpers.AssertString( computerName, @"Computer name cannot be empty" );
			var networkInfoList = new List<DprNetworkInfo>( );
			try {
				WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_NetworkAdapterConfiguration", obj => {
					var ci = new DprNetworkInfo( computerName );
					ci.DefaultIpGateway = WmiHelpers.GetStringArray( obj, @"DefaultIPGateway" );
					ci.Description = WmiHelpers.GetString( obj, @"Description" );
					ci.DhcpEnabled = WmiHelpers.GetBoolean( obj, @"DHCPEnabled" );
					ci.DhcpLeaseExpires = WmiHelpers.GetNullableDate( obj, @"DHCPLeaseExpires", true );
					ci.DhcpLeaseObtained = WmiHelpers.GetNullableDate( obj, @"DHCPLeaseObtained", true );
					ci.DhcpServer = WmiHelpers.GetString( obj, @"DHCPServer" );
					ci.DnsDomain = WmiHelpers.GetString( obj, @"DNSDomain" );
					ci.DnsDomainSuffixSearchOrder = WmiHelpers.GetStringArray( obj, @"DNSDomainSuffixSearchOrder" );
					ci.DnsEnabledForWinsResolution = WmiHelpers.GetNullableBoolean( obj, @"DNSEnabledForWINSResolution" );
					ci.DnsHostName = WmiHelpers.GetString( obj, @"DNSHostName" );
					ci.DnsServerSearchOrder = WmiHelpers.GetStringArray( obj, @"DNSServerSearchOrder" );
					ci.DomainDnsRegistrationEnabled = WmiHelpers.GetNullableBoolean( obj, @"DomainDNSRegistrationEnabled" );
					ci.FullDnsRegistrationEnabled = WmiHelpers.GetNullableBoolean( obj, @"FullDNSRegistrationEnabled" );
					ci.Index = WmiHelpers.GetUInt( obj, @"Index" );
					ci.InterfaceIndex = WmiHelpers.GetUInt( obj, @"InterfaceIndex" );
					ci.IpAddress = WmiHelpers.GetStringArray( obj, @"IPAddress" );
					ci.IpConnectionMetric = WmiHelpers.GetNullableUInt( obj, @"IPConnectionMetric" );
					ci.IpEnabled = WmiHelpers.GetNullableBoolean( obj, @"IPEnabled" );
					ci.MacAddress = WmiHelpers.GetString( obj, @"MACAddress" );
					ci.SettingId = WmiHelpers.GetString( obj, @"SettingID" );
					ci.WinsEnableLmHostsLookup = WmiHelpers.GetNullableBoolean( obj, @"WINSEnableLMHostsLookup" );
					ci.WinsHostLookupFile = WmiHelpers.GetString( obj, @"WINSHostLookupFile" );
					ci.WinsPrimaryServer = WmiHelpers.GetString( obj, @"WINSPrimaryServer" );
					ci.WinsSecondaryServer = WmiHelpers.GetString( obj, @"WINSSecondaryServer" );
					ci.WinsScopeId = WmiHelpers.GetString( obj, @"WINSScopeID" );

					networkInfoList.Add( ci );
					return true;
				}, true, false );
			} catch( UnauthorizedAccessException ) {
				result.Add( new DprNetworkInfo( computerName, ConnectionStatuses.AuthorizationError ) );
				return;
			} catch( Exception ) {
				result.Add( new DprNetworkInfo( computerName, ConnectionStatuses.Error ) );
				return;
			}
			result.AddRange( networkInfoList );
			ValidateUniqueness( result );
		}
//      public bool ShouldHide { get { return IsHidden( ); } }
//
//      private bool IsHidden( bool shown = false ) {
//          return !shown && SystemComponent;
//      }

        public static void Generate(string computerName, SyncList <DprComputerSoftware> result)
        {
            Debug.Assert(null != result, @"result SyncList cannot be null");
            Helpers.AssertString(computerName, @"Computer name cannot be empty");
            var softwareList = new List <DprComputerSoftware>();

            try {
                string[] regPaths =
                {
                    @"SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
                };
                foreach (var currentPath in regPaths)
                {
                    using (var regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(currentPath, false)) {
                        if (null == regKey)
                        {
                            continue;
                        }
                        foreach (var currentGuid in regKey.GetSubKeyNames( ).Where(currentValue => currentValue.StartsWith(@"{")).Where(currentGuid => !HasGuid(softwareList, currentGuid)))
                        {
                            using (var curReg = regKey.OpenSubKey(currentGuid, false)) {
                                if (null == curReg || !string.IsNullOrEmpty(RegistryHelpers.GetString(curReg, @"ParentKeyName")))
                                {
                                    continue;
                                }
                                var currentProduct = new DprComputerSoftware(computerName)
                                {
                                    Guid        = currentGuid,
                                    Name        = RegistryHelpers.GetString(curReg, @"DisplayName"),
                                    Publisher   = RegistryHelpers.GetString(curReg, @"Publisher"),
                                    Version     = RegistryHelpers.GetString(curReg, @"DisplayVersion"),
                                    InstallDate = RegistryHelpers.GetDateTime(curReg, @"InstallDate"),
                                    CanRemove   = 0 == RegistryHelpers.GetDword(curReg, @"NoRemove", 0),
                                    //SystemComponent = 1 == RegistryHelpers.GetDword( curReg, @"SystemComponent", 0 )
                                };
                                {
                                    var estSize = RegistryHelpers.GetDword(curReg, @"EstimatedSize");
                                    if (null != estSize)
                                    {
                                        currentProduct.Size = (float)Math.Round((float)estSize / 1024.0, 2, MidpointRounding.AwayFromZero);
                                    }
                                }

                                currentProduct.HelpLink     = RegistryHelpers.GetString(curReg, @"HelpLink");
                                currentProduct.UrlInfoAbout = RegistryHelpers.GetString(curReg, @"UrlInfoAbout");
                                if (currentProduct.Valid( ))
                                {
                                    softwareList.Add(currentProduct);
                                }
                            }
                        }
                    }
                }
            } catch (System.IO.IOException) {
                result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.ConnectionError));
                softwareList.Clear( );
            } catch (UnauthorizedAccessException) {
                result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.AuthorizationError));
                softwareList.Clear( );
            } catch (System.Security.SecurityException) {
                result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.AuthorizationError));
                softwareList.Clear( );
            }
            result.AddRange(softwareList);
            ValidateUniqueness(result);
        }
Пример #10
0
// 		public bool ShouldHide { get { return IsHidden( ); } }
// 
// 		private bool IsHidden( bool shown = false ) {
// 			return !shown && SystemComponent;
// 		}

		public static void Generate( string computerName, SyncList<DprComputerSoftware> result ) {
			Debug.Assert( null != result, @"result SyncList cannot be null" );
			Helpers.AssertString( computerName, @"Computer name cannot be empty" );
			var softwareList = new List<DprComputerSoftware>();
			try {
				string[] regPaths = {
					@"SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
				};
				foreach( var currentPath in regPaths ) {
					using( var regKey = RegistryKey.OpenRemoteBaseKey( RegistryHive.LocalMachine, computerName ).OpenSubKey( currentPath, false ) ) {
						if( null == regKey ) {
							continue;
						}
						foreach( var currentGuid in regKey.GetSubKeyNames( ).Where( currentValue => currentValue.StartsWith( @"{" ) ).Where( currentGuid => !HasGuid( softwareList, currentGuid ) ) ) {
							using( var curReg = regKey.OpenSubKey( currentGuid, false ) ) {
								if( null == curReg || !string.IsNullOrEmpty( RegistryHelpers.GetString( curReg, @"ParentKeyName" ) ) ) {
									continue;
								}
								var currentProduct = new DprComputerSoftware( computerName ) {
									Guid = currentGuid, 
									Name = RegistryHelpers.GetString( curReg, @"DisplayName" ), 
									Publisher = RegistryHelpers.GetString( curReg, @"Publisher" ), 
									Version = RegistryHelpers.GetString( curReg, @"DisplayVersion" ), 
									InstallDate = RegistryHelpers.GetDateTime( curReg, @"InstallDate" ), 
									CanRemove = 0 == RegistryHelpers.GetDword( curReg, @"NoRemove", 0 ), 
									//SystemComponent = 1 == RegistryHelpers.GetDword( curReg, @"SystemComponent", 0 )
								};
								{
									var estSize = RegistryHelpers.GetDword( curReg, @"EstimatedSize" );
									if( null != estSize ) {
										currentProduct.Size = (float)Math.Round( (float)estSize / 1024.0, 2, MidpointRounding.AwayFromZero );
									}
								}

								currentProduct.HelpLink = RegistryHelpers.GetString( curReg, @"HelpLink" );
								currentProduct.UrlInfoAbout = RegistryHelpers.GetString( curReg, @"UrlInfoAbout" );
								if( currentProduct.Valid( ) ) {
									softwareList.Add( currentProduct );
								}
							}
						}
					}
				}
			} catch( System.IO.IOException ) {
				result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.ConnectionError ) );
				softwareList.Clear( );
			} catch( UnauthorizedAccessException ) {
				result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.AuthorizationError ) );
				softwareList.Clear( );
			} catch( System.Security.SecurityException ) {
				result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.AuthorizationError ) );
				softwareList.Clear( );
			}
			result.AddRange( softwareList );
			ValidateUniqueness( result );
		}