/// <summary> /// Entry routine /// </summary> /// <param name="args"></param> static void Main(string[] args) { //Create a new logger instance Logger.Instance = new Logger { //Log everything Level = Log_level.L_DEBUG }; //Register for unhandled exceptions in the application AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Console.WriteLine(@" ______ __ __ ___ __ __ "); Console.WriteLine(@" / ____/_/ // /_ / | ____/ /___ _____ / /____ _____"); Console.WriteLine(@" / / /_ _ __/ / /| |/ __ / __ `/ __ \/ __/ _ \/ ___/"); Console.WriteLine(@"/ /___/_ _ __/ / ___ / /_/ / /_/ / /_/ / /_/ __/ / "); Console.WriteLine(@"\____/ /_//_/ /_/ |_\__,_/\__,_/ .___/\__/\___/_/ "); Console.WriteLine(@" /_/ "); Console.WriteLine(@"_________________________________________________________________"); //Parse the command line arguments if (!ParseCommandLineArguments(args)) { Logger.Log(Log_level.L_ERROR, "Cannot parse the command line arguments. Closing the adapter!"); return; } Console.WriteLine($"Adapter is reachable at: {address.Address}:{address.Port}"); Console.WriteLine($"Register is reachable at: {mmiRegisterAddress.Address}:{mmiRegisterAddress.Port}"); Console.WriteLine($"MMUs will be loaded from: {mmuPath}"); Console.WriteLine(@"_________________________________________________________________"); //Create the adapter description -> To do load from file in future MAdapterDescription adapterDescription = new MAdapterDescription() { Name = "CSharpAdapter", Addresses = new List <MIPAddress>() { address }, ID = "438543643-436436435-2354235", Language = "C#", Parameters = new List <MParameter>(), Properties = new Dictionary <string, string>() }; //Create a session cleaner for the utilized session data sessionCleaner = new SessionCleaner(sessionData) { //Session shoould be cleaned after 60 minutes Timeout = TimeSpan.FromMinutes(60), //The session cleaner should check every minute UpdateTime = TimeSpan.FromMinutes(1) }; //Start the session cleaner sessionCleaner.Start(); //Create a new adapter controller which scans the filesystem and checks for MMUs there using (AdapterController adapterController = new AdapterController(sessionData, adapterDescription, mmiRegisterAddress, new FileBasedMMUProvider(sessionData, new List <string>() { mmuPath }, new List <string>() { "C#", "C++CLR" }), new CSharpMMUInstantiator())) { //Start the adapter controller adapterController.Start(); Console.ReadLine(); } }
/// <summary> /// Basic awake method /// </summary> private void Awake() { //Determine if server build isServerBuild = IsHeadlessMode(); //Set the logger to a unity specific one (using debug log) MMICSharp.Adapter.Logger.Instance = new UnityLogger(isServerBuild) { //Log everything Level = Log_level.L_DEBUG }; //Assign the instance Instance = this; //Only visualizes the text if server build if (isServerBuild) { Console.WriteLine(@" __ __ _ __ ___ __ __ "); Console.WriteLine(@" / / / /___ (_) /___ __ / | ____/ /___ _____ / /____ _____"); Console.WriteLine(@" / / / / __ \/ / __ / / / / / /| |/ __ / __ `/ __ \/ __ / _ \/ ___ / "); Console.WriteLine(@"/ /_/ / / / / / /_/ /_/ / / ___ / /_/ / /_/ / /_/ / /_/ __/ / "); Console.WriteLine(@"\____/_/ /_/_/\__/\__, / /_/ |_\__,_/\__,_/ .___/\__/\___/_/ "); Console.WriteLine(@" /____/ /_/ "); Console.WriteLine(@"_________________________________________________________________"); } //Only use this if self_hosted and within edit mode -> Otherwise the launcher which starts the service assigns the address and port #if UNITY_EDITOR this.address.Address = "127.0.0.1"; this.address.Port = 8950; this.registerAddress.Port = 9009; this.registerAddress.Address = "127.0.0.1"; #else //Parse the command line arguments if (!this.ParseCommandLineArguments(System.Environment.GetCommandLineArgs())) { MMICSharp.Adapter.Logger.Log(Log_level.L_ERROR, "Cannot parse the command line arguments. The adapter is meant to be started with specified arguments only."); return; } #endif //Create a new session data this.sessionData = new SessionData(); //Create a session cleaner for the utilized session data this.sessionCleaner = new SessionCleaner(sessionData) { //Session shoould be cleaned after 60 minutes Timeout = TimeSpan.FromMinutes(60), //The session cleaner should check every minute UpdateTime = TimeSpan.FromMinutes(1) }; //Set the quality properties Application.targetFrameRate = 30; QualitySettings.SetQualityLevel(0, true); //Create an adapter description -> to do in future load properties such as the ID from file MAdapterDescription adapterDescription = new MAdapterDescription() { ID = "14456546241413414", Addresses = new List <MIPAddress>() { this.address }, Name = "UnityAdapter", Language = "UnityC#", Parameters = new List <MParameter>(), Properties = new Dictionary <string, string>() }; //Create a new adapter controller which listens on the file system and scans for MMUs this.adapterController = new AdapterController(this.sessionData, adapterDescription, mmiRegisterAddress, new FileBasedMMUProvider(sessionData, mmuPath, "UnityC#", "Unity"), new UnityMMUInstantiator()); //Log the startup info text MMICSharp.Adapter.Logger.Log(Log_level.L_INFO, $"Hosting thrift server at {this.address.Address} {this.address.Port}: "); }