/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="owner"><seealso cref="Simian"/> server that these extensions belong to</param> public static void LoadAllExtensions(string path, Simian owner) { // Load internal extensions LoadAssemblyExtensions(Assembly.GetExecutingAssembly(), owner); // Load extensions from external assemblies List<string> extensionNames = ListExtensionAssemblies(path); foreach (string name in extensionNames) LoadAssemblyExtensions(Assembly.LoadFile(name), owner); // Load extensions from external code files extensionNames = ListExtensionSourceFiles(path); foreach (string name in extensionNames) { CompilerResults results = CSCompiler.CompileAssemblyFromFile(CSCompilerParams, name); if (results.Errors.Count == 0) { LoadAssemblyExtensions(results.CompiledAssembly, owner); } else { Logger.Log("Error(s) compiling " + name, Helpers.LogLevel.Error); foreach (CompilerError error in results.Errors) Logger.Log(error.ToString(), Helpers.LogLevel.Error); } } }
public SimulationObject(SimulationObject obj) { Prim = new Primitive(obj.Prim); Server = obj.Server; LinkNumber = obj.LinkNumber; Frozen = obj.Frozen; // Skip everything else because it can be lazily reconstructed }
public bool Start(Simian simian) { m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS); m_watchdogTimer.AutoReset = false; m_watchdogTimer.Elapsed += WatchdogTimerElapsed; m_watchdogTimer.Start(); return(true); }
static void Main(string[] args) { Simian simulator = new Simian(); if (simulator.Start()) { Console.WriteLine("Simulator is running. Press ENTER to quit"); Console.ReadLine(); simulator.Stop(); } }
public bool Start(Simian simian) { m_simian = simian; int serializeSeconds = DEFAULT_SERIALIZATION_INTERVAL; string executingDir = Util.ExecutingDirectory(); m_storeDirectory = Path.Combine(executingDir, DEFAULT_STORE_DIRECTORY); IConfig config = simian.Config.Configs["FileDataStore"]; if (config != null) { string configPath = config.GetString("Path", DEFAULT_STORE_DIRECTORY); string tempPath = config.GetString("TempPath", DEFAULT_TEMP_STORE_DIRECTORY); serializeSeconds = config.GetInt("SaveInterval", DEFAULT_SERIALIZATION_INTERVAL); if (Path.IsPathRooted(configPath)) { m_storeDirectory = configPath; } else { m_storeDirectory = Path.Combine(executingDir, configPath); } if (Path.IsPathRooted(tempPath)) { m_tempStoreDirectory = tempPath; } else { m_tempStoreDirectory = Path.Combine(executingDir, tempPath); } } if (!Directory.Exists(m_storeDirectory)) { try { Directory.CreateDirectory(m_storeDirectory); } catch (Exception ex) { m_log.Error("Failed to create local file store directory " + m_storeDirectory + ": " + ex.Message); return(false); } } m_log.Debug("Serialization interval set to " + serializeSeconds + " seconds"); m_pendingSerialization = new ThrottledQueue <string, SerializedData>(0.1f, serializeSeconds * 1000, true, SerializeHandler); m_pendingSerialization.Start(); return(true); }
static void Main(string[] args) { Simian simulator = new Simian(); if (simulator.Start(9000, false)) { Console.WriteLine("Simulator is running. Press ENTER to quit"); Console.ReadLine(); simulator.Stop(); } }
public Scene(UUID sceneID, string sceneName, Vector3d scenePosition, Vector3d sceneSize, Simian simian, IConfigSource configSource) { m_simian = simian; m_configSource = configSource; m_httpServer = simian.GetAppModule <IHttpServer>(); m_id = sceneID; m_name = sceneName; m_regionPosition = scenePosition; m_regionSize = sceneSize; }
public UDPServer(int port, Simian server) : base(port) { this.server = server; Start(); // Start the incoming packet processing thread Thread incomingThread = new Thread(new ThreadStart(IncomingPacketHandler)); incomingThread.Start(); }
public bool Start(Simian simian) { m_dataStore = simian.GetAppModule <IDataStore>(); if (m_dataStore == null) { m_log.Error("MeshCache requires an IDataStore"); return(false); } return(true); }
/// <summary> /// The main entry point to activate the Simian. /// To run type Simian.exe ConfigName RulesName /// </summary> /// <param name="args">The exeName followed by config and script</param> public static void Main(string[] args) { // set up this simian from the default config file or that specified. string ConfigFile = null; if (args.Length > 1) { if (args[1].Length > 0 && args[1] != "") ConfigFile = args[1]; } Simian monkey = new Simian(ConfigFile); //Sensact testing = new Sensact(@"C:\Testing\XP\Simian\SimianRules.xml", monkey, monkey); Sensact testing = new Sensact(@"C:\Testing\XP\Simian\NavRules.xml", monkey, monkey); bool instruct = testing.setGoal(null); // use the one in the rules file bool done = testing.act(); Log log = Log.getOnly(); log.endElt(); // end the log }
/// <summary> /// The main entry point to activate the Simian. /// To run type Simian.exe ConfigName RulesName /// </summary> /// <param name="args">The exeName followed by config and script</param> public static void Main(string[] args) { // set up this simian from the default config file or that specified. string ConfigFile = null; if (args.Length > 1) { if (args[1].Length > 0 && args[1] != "") { ConfigFile = args[1]; } } Simian monkey = new Simian(ConfigFile); //Sensact testing = new Sensact(@"C:\Testing\XP\Simian\SimianRules.xml", monkey, monkey); Sensact testing = new Sensact(@"C:\Testing\XP\Simian\NavRules.xml", monkey, monkey); bool instruct = testing.setGoal(null); // use the one in the rules file bool done = testing.act(); Log log = Log.getOnly(); log.endElt(); // end the log }
public bool Start(Simian simian) { m_simian = simian; int serializeSeconds = DEFAULT_SERIALIZATION_INTERVAL; string executingDir = Util.ExecutingDirectory(); m_storeDirectory = Path.Combine(executingDir, DEFAULT_STORE_DIRECTORY); IConfig config = simian.Config.Configs["FileDataStore"]; if (config != null) { string configPath = config.GetString("Path", DEFAULT_STORE_DIRECTORY); string tempPath = config.GetString("TempPath", DEFAULT_TEMP_STORE_DIRECTORY); serializeSeconds = config.GetInt("SaveInterval", DEFAULT_SERIALIZATION_INTERVAL); if (Path.IsPathRooted(configPath)) m_storeDirectory = configPath; else m_storeDirectory = Path.Combine(executingDir, configPath); if (Path.IsPathRooted(tempPath)) m_tempStoreDirectory = tempPath; else m_tempStoreDirectory = Path.Combine(executingDir, tempPath); } if (!Directory.Exists(m_storeDirectory)) { try { Directory.CreateDirectory(m_storeDirectory); } catch (Exception ex) { m_log.Error("Failed to create local file store directory " + m_storeDirectory + ": " + ex.Message); return false; } } m_log.Debug("Serialization interval set to " + serializeSeconds + " seconds"); m_pendingSerialization = new ThrottledQueue<string, SerializedData>(0.1f, serializeSeconds * 1000, true, SerializeHandler); m_pendingSerialization.Start(); return true; }
public bool Start(Simian simian) { m_dataStore = simian.GetAppModule<IDataStore>(); if (m_dataStore == null) { m_log.Error("MeshCache requires an IDataStore"); return false; } return true; }
public bool Start(Simian simian) { int port = DEFAULT_HTTP_PORT; string hostname = null; string sslCertFile = null; IPHostEntry entry; IPAddress address; // Create a logger for the HTTP server HttpLogWriter httpLogger = new HttpLogWriter(m_log); // Create a default 404 handler m_notFoundHandler = new HttpRequestHandler(null, Default404Handler, true); #region Config Variables IConfig config = simian.Config.Configs["HTTP"]; if (config != null) { port = config.GetInt("ListenPort", DEFAULT_HTTP_PORT); hostname = config.GetString("Hostname", null); sslCertFile = config.GetString("SSLCertFile", null); } if (String.IsNullOrEmpty(hostname)) { hostname = Dns.GetHostName(); entry = Dns.GetHostEntry(hostname); address = IPAddress.Any; } else { entry = Dns.GetHostEntry(hostname); if (entry != null && entry.AddressList.Length > 0) { address = entry.AddressList[0]; } else { m_log.Warn("Could not resolve an IP address from hostname " + hostname + ", binding to all interfaces"); address = IPAddress.Any; } } #endregion Config Variables #region Initialization if (!String.IsNullOrEmpty(sslCertFile)) { // HTTPS mode try { m_sslCertificate = new X509Certificate2(sslCertFile); } catch (Exception ex) { m_log.Error("Failed to load SSL certificate file \"" + sslCertFile + "\": " + ex.Message); return false; } m_uri = new Uri("https://" + hostname + (port != 80 ? (":" + port) : String.Empty)); m_httpServer = HttpServer.HttpListener.Create(address, port, m_sslCertificate, RemoteCertificateValidationHandler, SslProtocols.Default, false); } else { // HTTP mode m_uri = new Uri("http://" + hostname + (port != 80 ? (":" + port) : String.Empty)); m_httpServer = HttpServer.HttpListener.Create(address, port); } m_httpServer.LogWriter = httpLogger; m_httpServer.RequestReceived += RequestReceivedHandler; m_httpServer.Start(64); m_log.Info("HTTP server is listening at " + m_uri); #endregion Initialization return true; }
static void Main(string[] args) { bool coloredLogging = true; bool printHelp = false; bool printVersion = false; // Name the main thread Thread.CurrentThread.Name = "Main"; #region Command Line Argument Handling Mono.Options.OptionSet set = new Mono.Options.OptionSet() { { "nocolor", "Disable colored console logging", v => coloredLogging = false }, { "h|?|help", "Shows launch options", v => printHelp = true }, { "version", "Show version information", v => printVersion = true } }; set.Parse(args); if (printHelp) { set.WriteOptionDescriptions(Console.Out); return; } if (printVersion) { string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Console.WriteLine("Simian " + version); return; } #endregion Command Line Argument Handling #region log4net Setup // If error level reporting isn't enabled we assume no logger is configured and initialize a default appender if (!m_log.Logger.IsEnabledFor(log4net.Core.Level.Error)) { log4net.Appender.AppenderSkeleton appender; if (coloredLogging) { log4net.Appender.ColoredConsoleAppender coloredAppender = new log4net.Appender.ColoredConsoleAppender(); var mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Debug; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.HighIntensity; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Info; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Warn; mapping.BackColor = log4net.Appender.ColoredConsoleAppender.Colors.Purple; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Error; mapping.BackColor = log4net.Appender.ColoredConsoleAppender.Colors.Red; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); appender = coloredAppender; } else { appender = new log4net.Appender.ConsoleAppender(); } appender.Layout = new log4net.Layout.PatternLayout("%timestamp [%thread] %-5level %logger - %message%newline"); appender.ActivateOptions(); BasicConfigurator.Configure(appender); m_log.Info("No log configuration found, defaulting to console logging"); } // Hook up Debug.Assert statements to log4net Debug.Listeners.Insert(0, new log4netTraceListener()); #endregion log4net Setup // Set the working directory to the application dir Directory.SetCurrentDirectory(Util.ExecutingDirectory()); // Initialize the Simian object m_simian = new Simian(); // Handle Ctrl+C Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; m_simian.Shutdown(); m_running = false; }; // Attempt to load modules if (m_simian.LoadModules()) { // Initialize the interactive console InteractiveConsole(); } else { m_log.Error("Application module loading failed, shutting down"); } }
public SceneManager(Simian server) { this.server = server; }
public bool Start(Simian server, RegionInfo regionInfo, X509Certificate2 regionCert, string defaultTerrainFile, int staticObjects, int physicalObjects) { running = true; this.server = server; this.regionName = regionInfo.Name; this.endpoint = regionInfo.IPAndPort; this.regionID = regionInfo.ID; this.regionCert = regionCert; this.regionFlags = regionInfo.Flags; this.mapTextureID = regionInfo.MapTextureID; this.waterHeight = regionInfo.WaterHeight; // Set the properties because this will automatically update the regionHandle RegionX = regionInfo.X; RegionY = regionInfo.Y; #region ISceneProvider Extension Loading try { // Create a list of references for .cs extensions that are compiled at runtime List<string> references = new List<string>(); references.Add("OpenMetaverseTypes.dll"); references.Add("OpenMetaverse.dll"); references.Add("Simian.exe"); // Load extensions from the current executing assembly, Simian.*.dll assemblies on disk, and // Simian.*.cs source files on disk. extensions.LoadAllExtensions(Assembly.GetExecutingAssembly(), AppDomain.CurrentDomain.BaseDirectory, server.ExtensionList, references, "Simian.*.dll", "Simian.*.cs"); // Automatically assign extensions that implement interfaces to the list of interface // variables in "assignables" extensions.AssignExtensions(this, extensions.GetInterfaces(this)); // Start all of the extensions foreach (IExtension<ISceneProvider> extension in extensions.Extensions) { // Only print the extension names if this is the first loaded scene if (server.Scenes.Count == 0) Logger.Log("Starting Scene extension " + extension.GetType().Name, Helpers.LogLevel.Info); extension.Start(this); } } catch (ExtensionException ex) { Logger.Log("SceneManager extension loading failed, shutting down: " + ex.Message, Helpers.LogLevel.Error); Stop(); return false; } #endregion ISceneProvider Extension Loading // Callback registration server.Grid.OnRegionUpdate += Grid_OnRegionUpdate; udp.OnAgentConnection += udp_OnAgentConnection; udp.RegisterPacketCallback(PacketType.CompleteAgentMovement, CompleteAgentMovementHandler); // Load the default terrain for this sim if (!String.IsNullOrEmpty(defaultTerrainFile)) LoadTerrain(Simian.DATA_DIR + defaultTerrainFile); // Start the physics thread Thread physicsThread = new Thread(new ThreadStart(PhysicsThread)); physicsThread.Name = "Physics"; physicsThread.Start(); Logger.Log(String.Format("Region {0} online at ({1},{2}) listening on {3}", regionName, regionX, regionY, endpoint), Helpers.LogLevel.Info); // Tell the grid that this region is online regionInfo.Online = true; server.Grid.RegionUpdate(regionInfo, regionCert); return true; }
public SimulationObject(Primitive prim, Simian server) { Prim = prim; Server = server; }
public static void LoadAssemblyExtensions(Assembly assembly, Simian owner) { foreach (Type t in assembly.GetTypes()) { try { if (t.GetInterface("ISimianExtension") != null) { ConstructorInfo info = t.GetConstructor(new Type[] { typeof(Simian) }); ISimianExtension extension = (ISimianExtension)info.Invoke(new object[] { owner }); Extensions.Add(extension); } } catch (Exception e) { Logger.Log("LoadAssemblyExtensions(): " + e.Message, Helpers.LogLevel.Warning); } } }
public ConnectionManagement(Simian server) { this.server = server; }
public bool Start(Simian simian) { int port = DEFAULT_HTTP_PORT; string hostname = null; string sslCertFile = null; IPHostEntry entry; IPAddress address; // Create a logger for the HTTP server HttpLogWriter httpLogger = new HttpLogWriter(m_log); // Create a default 404 handler m_notFoundHandler = new HttpRequestHandler(null, Default404Handler, true); #region Config Variables IConfig config = simian.Config.Configs["HTTP"]; if (config != null) { port = config.GetInt("ListenPort", DEFAULT_HTTP_PORT); hostname = config.GetString("Hostname", null); sslCertFile = config.GetString("SSLCertFile", null); } if (String.IsNullOrEmpty(hostname)) { hostname = Dns.GetHostName(); entry = Dns.GetHostEntry(hostname); address = IPAddress.Any; } else { entry = Dns.GetHostEntry(hostname); if (entry != null && entry.AddressList.Length > 0) { address = entry.AddressList[0]; } else { m_log.Warn("Could not resolve an IP address from hostname " + hostname + ", binding to all interfaces"); address = IPAddress.Any; } } #endregion Config Variables #region Initialization if (!String.IsNullOrEmpty(sslCertFile)) { // HTTPS mode try { m_sslCertificate = new X509Certificate2(sslCertFile); } catch (Exception ex) { m_log.Error("Failed to load SSL certificate file \"" + sslCertFile + "\": " + ex.Message); return(false); } m_uri = new Uri("https://" + hostname + (port != 80 ? (":" + port) : String.Empty)); m_httpServer = HttpServer.HttpListener.Create(address, port, m_sslCertificate, RemoteCertificateValidationHandler, SslProtocols.Default, false); } else { // HTTP mode m_uri = new Uri("http://" + hostname + (port != 80 ? (":" + port) : String.Empty)); m_httpServer = HttpServer.HttpListener.Create(address, port); } m_httpServer.LogWriter = httpLogger; m_httpServer.RequestReceived += RequestReceivedHandler; m_httpServer.Start(64); m_log.Info("HTTP server is listening at " + m_uri); #endregion Initialization return(true); }
public void Start() { simian = new Simian.Simian(); simian.UDP = new UDPManager(); (simian.UDP as IExtension<Simian.Simian>).Start(simian); sceneManager = new SceneManager(); sceneManager.Start(simian); agent = CreateDummyAgent(); simian.Agents.Add(agent.Avatar.ID, agent); observer = CreateDummyAgent(); simian.Agents.Add(observer.Avatar.ID, observer); }
static void Main(string[] args) { bool coloredLogging = true; bool printHelp = false; bool printVersion = false; // Name the main thread Thread.CurrentThread.Name = "Main"; #region Command Line Argument Handling Mono.Options.OptionSet set = new Mono.Options.OptionSet() { { "nocolor", "Disable colored console logging", v => coloredLogging = false }, { "h|?|help", "Shows launch options", v => printHelp = true }, { "version", "Show version information", v => printVersion = true } }; set.Parse(args); if (printHelp) { set.WriteOptionDescriptions(Console.Out); return; } if (printVersion) { string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Console.WriteLine("Simian " + version); return; } #endregion Command Line Argument Handling #region log4net Setup // If error level reporting isn't enabled we assume no logger is configured and initialize a default appender if (!m_log.Logger.IsEnabledFor(log4net.Core.Level.Error)) { log4net.Appender.AppenderSkeleton appender; if (coloredLogging) { log4net.Appender.ColoredConsoleAppender coloredAppender = new log4net.Appender.ColoredConsoleAppender(); var mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Debug; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.HighIntensity; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Info; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Warn; mapping.BackColor = log4net.Appender.ColoredConsoleAppender.Colors.Purple; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); mapping = new log4net.Appender.ColoredConsoleAppender.LevelColors(); mapping.Level = log4net.Core.Level.Error; mapping.BackColor = log4net.Appender.ColoredConsoleAppender.Colors.Red; mapping.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.White; coloredAppender.AddMapping(mapping); appender = coloredAppender; } else { appender = new log4net.Appender.ConsoleAppender(); } appender.Layout = new log4net.Layout.PatternLayout("%timestamp [%thread] %-5level %logger - %message%newline"); appender.ActivateOptions(); BasicConfigurator.Configure(appender); m_log.Info("No log configuration found, defaulting to console logging"); } // Hook up Debug.Assert statements to log4net Debug.Listeners.Insert(0, new log4netTraceListener()); #endregion log4net Setup // Set the working directory to the application dir Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); // Initialize the Simian object m_simian = new Simian(); // Handle Ctrl+C Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; m_simian.Shutdown(); m_running = false; }; // Attempt to load modules if (m_simian.LoadModules()) { // Initialize the interactive console InteractiveConsole(); } else { m_log.Error("Application module loading failed, shutting down"); } }
public bool Start(Simian simian) { m_simian = simian; int serializeSeconds = DEFAULT_SERIALIZATION_INTERVAL; // Regular expression to replace invalid path and filename characters m_invalidPathCharsRegex = "[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]"; string executingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); m_storeDirectory = Path.Combine(executingDir, DEFAULT_STORE_DIRECTORY); IConfig config = simian.Config.Configs["FileDataStore"]; if (config != null) { string configPath = config.GetString("Path", DEFAULT_STORE_DIRECTORY); string tempPath = config.GetString("TempPath", DEFAULT_TEMP_STORE_DIRECTORY); serializeSeconds = config.GetInt("SaveInterval", DEFAULT_SERIALIZATION_INTERVAL); if (Path.IsPathRooted(configPath)) m_storeDirectory = configPath; else m_storeDirectory = Path.Combine(executingDir, configPath); if (Path.IsPathRooted(tempPath)) m_tempStoreDirectory = tempPath; else m_tempStoreDirectory = Path.Combine(executingDir, tempPath); } if (!Directory.Exists(m_storeDirectory)) { try { Directory.CreateDirectory(m_storeDirectory); } catch (Exception ex) { m_log.Error("Failed to create local file store directory " + m_storeDirectory + ": " + ex.Message); return false; } } m_log.Debug("Serialization interval set to " + serializeSeconds + " seconds"); m_pendingSerialization = new ThrottledQueue<string, SerializedData>(0.1f, serializeSeconds * 1000, true, SerializeHandler); m_pendingSerialization.Start(); return true; }