/// <summary>
        /// Create Host for MA environment
        /// </summary>
        /// <returns></returns>
        private IHost CreateHost()
        {
            string modelCachePath = PlatformManager.DefaultModelCompilationCacheDirectory;
            string codecCachePath = Path.Combine(PlatformManager.BaseDirectory, "CodecCache");
            //Create and register a host
            var host = new SimpleHost();
            SimpleModelManager modelManager = new SimpleModelManager(modelCachePath);

            host.SetModelManager(modelManager);
            new RuntimeTechnology().Register(host);
            new CoreTechnology().Register(host);
            new OPNTechnology().Register(host);
            new CompilerTechnology().Register(host);
            // host.RegisterService(new CertificateStore());

            var ext = new ExtensionContainer(PlatformManager.ExtensionsDirectory);

            foreach (var tech in ext.technologies)
            {
                tech.Register(host);
            }

            var runtimeProps = host.GetService <RuntimeProperties>();

            runtimeProps.AssemblyCachePath = modelCachePath;
            var compilerProps = host.GetService <CompilerProperties>();

            compilerProps.CodecCacheFolder = codecCachePath;

            host.EndRegistration();
            return(host);
        }
        /// <summary>
        /// Create Host for MA environment when MA has been installed
        /// </summary>
        /// <returns></returns>
        private IHost CreateHostForMAInstalled()
        {
            var compilationCachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "MessageAnalyzer", "CompilationCache");
            var codecCachePath       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "MessageAnalyzer", "CodecCache");

            //Create and register a host
            SimpleHost         host         = new SimpleHost();
            SimpleModelManager modelManager = new SimpleModelManager(compilationCachePath);

            host.SetModelManager(modelManager);

            new CoreTechnology(StandardStages.Runtime).Register(host);
            new RuntimeTechnology().Register(host);
            new OPNTechnology().Register(host);
            new CompilerTechnology().Register(host);

            var ext = new ExtensionContainer(PlatformManager.ExtensionsDirectory);

            foreach (var tech in ext.technologies)
            {
                tech.Register(host);
            }

            var runtimeProps = host.GetService <RuntimeProperties>();

            runtimeProps.AssemblyCachePath = compilationCachePath;

            var compilerProps = host.GetService <CompilerProperties>();

            compilerProps.CodecCacheFolder = codecCachePath;

            host.EndRegistration();
            return(host);
        }
Exemplo n.º 3
0
 public WebServer(ILogger <StatisticWebOutput> logger)
 {
     Logger = logger;
     Host   = new SimpleHostBuilder()
              .ConfigureServer((server) => server.ListenLocalPort(11111))
              .Build();
 }
Exemplo n.º 4
0
        /* Setup */
        public Host(Loader loader)
        {
            _loader     = loader;
            _simpleHost = new SimpleHost <MessageType>(true);
            RegisterFunctions();
            _simpleHost.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);

#if DEBUG
            _simpleHost.NetManager.DisconnectTimeout = Int32.MaxValue;
#endif
        }
        /// <summary>
        /// Creates a client capable to communicating with a running remote control host inside a given process.
        /// </summary>
        /// <exception cref="FileNotFoundException">Server not running inside foreign process.</exception>
        public Client(Process process)
        {
            SimpleHost = new SimpleHost <MessageType>(false);
            SimpleHost.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);
            SimpleHost.NetManager.Connect(new IPEndPoint(IPAddress.Loopback, ServerLocator.GetPortOfServer(process.Id)), "");

            #if DEBUG
            SimpleHost.NetManager.DisconnectTimeout = Int32.MaxValue;
            _timeout = Int32.MaxValue;
            #endif
        }
Exemplo n.º 6
0
        public Client(int port)
        {
            _simpleHost = new SimpleHost <MessageType>(false);
            _simpleHost.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);
            _simpleHost.NetManager.Connect(new IPEndPoint(IPAddress.Loopback, port), "");

#if DEBUG
            _simpleHost.NetManager.DisconnectTimeout = Int32.MaxValue;
#endif

            _simpleHost.MessageHandler.AddOrOverrideHandler <GenericExceptionResponse>(ReceiveException);
        }
Exemplo n.º 7
0
 static void Main()
 {
     SimpleHost.StartAsConosle("http://localhost:8082",
                               server =>
     {
         Console.WriteLine("Press Enter to quit.");
         Console.WriteLine("---------------------");
         server.Configuration.OutputRouts(Console.WriteLine);
         Console.WriteLine("---------------------");
         Console.ReadLine();
     });
 }
Exemplo n.º 8
0
        private void InitUI()
        {
            uiSimpleHost = new SimpleHost();

            const float rectWidth  = 200f;
            const float rectHeight = 30f;

            uiEngineRectangle    = new Rectangle();
            uiBattalionRectangle = new Rectangle();
            uiRescueRectangle    = new Rectangle();

            uiEngineRectangle.Location    = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 - rectWidth * 1.75f, 40));
            uiBattalionRectangle.Location = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 - rectWidth * 0.5f, 40));
            uiRescueRectangle.Location    = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 + rectWidth * 0.75f, 40));

            uiEngineRectangle.Size = uiBattalionRectangle.Size = uiRescueRectangle.Size = AdvancedUI.Util.ConvertToCurrentCoordSystem(new SizeF(rectWidth, rectHeight));

            uiEngineRectangle.Color = uiBattalionRectangle.Color = uiRescueRectangle.Color = Color.FromArgb(165, 5, 5, 5);

            uiEngineLabel    = new Label();
            uiBattalionLabel = new Label();
            uiRescueLabel    = new Label();

            uiEngineLabel.Text    = FirefighterRole.Engine.ToString();
            uiBattalionLabel.Text = FirefighterRole.Battalion.ToString();
            uiRescueLabel.Text    = FirefighterRole.Rescue.ToString();

            uiEngineLabel.Alignment = uiBattalionLabel.Alignment = uiRescueLabel.Alignment = TextAlignment.Center;

            uiEngineLabel.Color = uiBattalionLabel.Color = uiRescueLabel.Color = Color.White;

            uiEngineLabel.Location    = new PointF(uiEngineRectangle.Location.X + uiEngineRectangle.Size.Width / 2, uiEngineRectangle.Location.Y);
            uiBattalionLabel.Location = new PointF(uiBattalionRectangle.Location.X + uiBattalionRectangle.Size.Width / 2, uiBattalionRectangle.Location.Y);
            uiRescueLabel.Location    = new PointF(uiRescueRectangle.Location.X + uiRescueRectangle.Size.Width / 2, uiRescueRectangle.Location.Y);

            uiSelectionRectangle          = new Rectangle();
            uiSelectionRectangle.Color    = Color.FromArgb(160, Color.Red);
            uiSelectionRectangle.Size     = new SizeF(rectWidth + 10, rectHeight + 10);
            uiSelectionRectangle.Location = new PointF(uiEngineRectangle.Location.X - 5, uiEngineRectangle.Location.Y - 5);

            uiSimpleHost.Elements.Add(uiSelectionRectangle);
            uiSimpleHost.Elements.Add(uiEngineRectangle);
            uiSimpleHost.Elements.Add(uiBattalionRectangle);
            uiSimpleHost.Elements.Add(uiRescueRectangle);
            uiSimpleHost.Elements.Add(uiEngineLabel);
            uiSimpleHost.Elements.Add(uiBattalionLabel);
            uiSimpleHost.Elements.Add(uiRescueLabel);

            uiSimpleHost.Elements.ShowAll();
        }
Exemplo n.º 9
0
        public TestingHosts()
        {
            SimpleServer = new SimpleHost <MessageType>(true, DefaultPassword);
            SimpleClient = new SimpleHost <MessageType>(false, DefaultPassword);

            SimpleServer.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);
            SimpleClient.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);
            SimpleClient.NetManager.Connect(new IPEndPoint(IPAddress.Loopback, SimpleServer.NetManager.LocalPort), DefaultPassword);

#if DEBUG
            SimpleServer.NetManager.DisconnectTimeout = int.MaxValue;
            SimpleClient.NetManager.DisconnectTimeout = int.MaxValue;
#endif
        }
Exemplo n.º 10
0
        /* Server Setup */
        public Server(ILogger logger)
        {
            _simpleHost = new SimpleHost <MessageType>(true);
            _logger     = logger;
            RegisterFunctions();

            _simpleHost.NetManager.UnsyncedEvents = false;
            _simpleHost.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0);
            _queue         = new MessageQueue(this);
            _serverLocator = ServerLocator.RegisterPortForServer(Port);

            #if DEBUG
            _simpleHost.NetManager.DisconnectTimeout = Int32.MaxValue;
            #endif
        }
Exemplo n.º 11
0
    static void Main(string[] args)
    {
        // TODO: Check to see if a given argument has been passed on the command-line
        SimpleHost host = (SimpleHost)ApplicationHost.CreateApplicationHost(
            typeof(SimpleHost), "/", Directory.GetCurrentDirectory());

        HttpListener listener = new HttpListener();

        listener.Prefixes.Add("http://localhost:9999/");
        listener.Start();
        Console.WriteLine("Listening for requests on http://localhost:9999/");

        while (true)
        {
            HttpListenerContext context = listener.GetContext();
            string page  = context.Request.Url.LocalPath.Replace("/", "");
            string query = context.Request.Url.Query.Replace("?", "");
            using (var writer = new StreamWriter(context.Response.OutputStream))
            {
                host.ProcessRequest(page, query, writer);
            }
            context.Response.Close();
        }
    }