示例#1
0
文件: Program.cs 项目: renwoox/prime
        private void RunWs(MessagingServer.Server server, ServerContext sctx)
        {
            var manager = new ManagerServiceExtension();

            manager.Main(sctx);

            var wsServerExt = new Prime.WebSocketServer.ServerExtension();

            server.Inject(wsServerExt);
            wsServerExt.Start(server);
        }
示例#2
0
文件: Program.cs 项目: renwoox/prime
        private void Run()
        {
            var logger = new ConsoleLogger()
            {
                IncludePreamble = true
            };

            logger.Log("OS: " + Environment.OSVersion.Platform);
            logger.Log("Current directory: " + Environment.CurrentDirectory);

            var sCtx = new ServerContext()
            {
                L = logger
            };

            sCtx.Assemblies.Refresh();
            sCtx.Types.Refresh();

            // Run Prime.
            var prime = new PrimeInstance(sCtx);

            prime.ExtensionManager.LoadInstallConfig();
            prime.Start();

            // Run Messaging Server.
            var server = new MessagingServer.Server(sCtx);

            server.M.Register <HelloRequest>(this, (request) => { logger.Log($"{request.GetType()} received."); });

            logger.Log("Prime started");

            server.Start();

            // HACK. Run WS server. Unable to load it using extension manager.
            RunWs(server, sCtx);
            // END HACK.

            // Run command processor.
            var commandProcessor = new CommandProcessor();

            commandProcessor.Bind("exit", (cmd) => { Environment.Exit(0); });


            Console.ReadKey();
            //commandProcessor.Start();
        }
示例#3
0
 public PrimeWsServer(ServerContext serverContext, Server messagingServer)
 {
     _serverContext   = serverContext;
     _messagingServer = messagingServer;
 }
示例#4
0
文件: Program.cs 项目: renwoox/prime
        static void Main(string[] args)
        {
            Console.WriteLine("--- Prime Core ---");
            var logger = new ConsoleLogger()
            {
                IncludePreamble = true
            };

            // Initialization.
            var serverContext = new ServerContext()
            {
                L = logger
            };

            serverContext.Assemblies.Refresh();
            serverContext.Types.Refresh();

            var messagingServer = new MessagingServer.Server(serverContext);

            // Run TCP server for interproc communication with extensions.
            var primeTcp = new PrimeSocketServer(serverContext, messagingServer)
            {
                L = logger
            };

            primeTcp.Start();

            // Run WebSocket server.
            var primeWs = new PrimeWsServer(serverContext, messagingServer)
            {
                L = logger
            };

            primeWs.Start();

            // Run Prime Web.
            var primeWeb = new PrimeWeb()
            {
                L = logger
            };

            primeWeb.Run();

            // Demo messages handling.
            //messagingServer.M.Register<TimeKindUiUpdatedMessage>(logger, (r) =>
            //{
            //    messagingServer.M.Send(new UpdateTimeKindInternalRequestMessage()
            //    {
            //        IsUtc = r.IsUtc
            //    });
            //});

            //messagingServer.M.Register<TimeKindUpdatedMessage>(logger, (r) =>
            //{
            //    messagingServer.M.SendAsync(new TimeKindUiUpdatedMessage()
            //    {
            //        IsUtc = r.IsUtcTime
            //    });
            //});
            //

            messagingServer.Start();

            // Wait for input.
            Console.ReadKey();
        }
示例#5
0
 public PrimeSocketServer(ServerContext serverContext, MessagingServer.Server messagingServer)
 {
     _serverContext   = serverContext;
     _messagingServer = messagingServer;
 }