Exemple #1
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            var timed = db.Act.create(timedTick);

            m_sys.future(timed, 10.0, 0.0);
        }
Exemple #2
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            timedTick();

            var load = db.Act.create(loadEntities);

            m_sys.next(load);
        }
Exemple #3
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            var mode = new SFML.Window.VideoMode(1280, 1024);

            m_window             = new SFML.Graphics.RenderWindow(mode, "Client");
            m_window.KeyPressed += Window_KeyPressed;

            m_state = State.Running;
        }
Exemple #4
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            var address = new RTAddress(s_mgr.Id, id);

            log.info($"Starting up {cfg.res.services.Length} services");
            foreach (var svc in cfg.res.services)
            {
                send(svc, address);
            }
        }
Exemple #5
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            m_db = new ent.DB();

            m_sys = new ent.Sys(cfg.res.SystemCfg, m_db);

            m_sys.start();

            m_dbState = DBState.Running;

            var act = db.Act.create(frameTick);

            m_sys.next(act);

            /*
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             *
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             *
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             *
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             * m_sys.next( act );
             * //*/
        }
Exemple #6
0
        public void handle(msg.StartService start)
        {
            Type[]   types = new Type[1];
            object[] parms = new object[1];

            //types[0] = typeof( lib.Token );

            Type svcType = Type.GetType(start.type);

            if (svcType != null)
            {
                // @@@ DEPENDENCY This implies that all services are a subclass of a class that has 1
                // generic argument that is its config type
                Type cfgType = svcType.BaseType.GenericTypeArguments[0];

                //res.Ref cfg = res.Mgr.lookup( start.configPath, cfgType );

                var refGenType = typeof(res.Ref <>);

                var refType = refGenType.MakeGenericType(cfgType);

                var cfg = Activator.CreateInstance(refType, start.configPath);

                if (cfg != null)
                {
                    types[0] = cfg.GetType();

                    ConstructorInfo cons = svcType.GetConstructor(types);

                    try
                    {
                        //parms[0] = new lib.Token( start.name );
                        parms[0] = cfg;

                        log.info($"Starting service {"unknown"} of type {refType.Name} using config {start.configPath}");

                        svc.Service <msg.Msg> newService = (svc.Service <msg.Msg>)cons.Invoke(parms);

                        s_mgr.start(newService);



                        var startupMsg = new msg.Startup {
                        };

                        var svcAddress = new RTAddress(s_mgr.Id, newService.id);

                        //var delayMsg = new msg.DelaySend { address = svcAddress, msg = startupMsg };


                        //s_mgr.send(  )

                        send(startupMsg, svcAddress);
                    }
                    catch (Exception ex)
                    {
                        log.error($"Exception while calling service constructor {ex}");
                    }
                }
                else
                {
                    log.warn($"Could not find service of type {start.type}");
                }
            }
            else
            {
                log.warn($"Could not find service of type {start.type}");
            }
        }
Exemple #7
0
        public Main(string configPath)
        {
            main = this;

            /* Konsole Logging
             * s_fullscreenWin = new Window();
             * s_fullscreenWin.BackgroundColor = ConsoleColor.DarkGray;
             * s_fullscreenWin.Clear( ConsoleColor.DarkGray );
             *
             * var xStart = 2;
             * var yStart = 2;
             *
             * var xSize = s_fullscreenWin.WindowWidth  - xStart * 2;
             * var ySize = s_fullscreenWin.WindowHeight - yStart * 2;
             *
             * s_logWin = Window.Open( xStart, yStart, xSize, ySize, "Logging" );
             * //1*/

            net.App.startup();

            Process p = Process.GetCurrentProcess();

            var t = DateTime.Now;

            var date = $"{t.Year}{t.Month:D2}{t.Day:D2}_{t.Hour:D2}{t.Minute:D2}";

            string logpath = $"logs/{Environment.MachineName}_{date}_{p.Id}.log";


            log.create(logpath);

            log.addDelegate(logOut);

            log.info($"Saving log to [{logpath}]");


            //Log examples of each log type
            log.trace($"Trace test");
            log.debug($"Debug test");
            log.info($"Info test");
            log.high($"High test");
            log.warn($"Warn test");
            log.error($"Error test");
            log.fatal($"Fatal test");



            //*
            log.info($"Command line {Environment.CommandLine}");
            log.info($"Current working directory {Environment.CurrentDirectory}");

            log.info($"Running as {( Environment.Is64BitProcess ? "64" : "32" )}bit on a {( Environment.Is64BitOperatingSystem ? "64" : "32" )}bit machine.");
            log.info($"This machine has {Environment.ProcessorCount} processors.");

            log.info($"Currently given {Environment.WorkingSet} memory");
            log.info($"System page size of {Environment.SystemPageSize}");

            log.info($"Running on CLR {Environment.Version}");
            log.info($"Running on {Environment.OSVersion}");

            log.info($"Running as {Environment.UserName}");
            //*/


            /*
             * var test = new TestCalls();
             * test.runAllTests();
             * /*/
            log.info($"Skipping tests.");
            //*/



            //Serializer.Use( new svc.CerasSerializerForShielded() );


            res.Mgr.startup();
            lib.Config.startup("server_config.cfg");


            //Load configs
            log.info($"Loading config {configPath}");
            //m_cfg = lib.Config.load<ServerCfg>( configPath );
            m_cfg = res.Mgr.lookup <ServerCfg>(configPath);


            // @@ TODO Move to specific
            lib.Util.checkAndAddDirectory("logs");
            // save/static and save/dynamic are created when they dont exist in order to create the universe
            lib.Util.checkAndAddDirectory("save/players");


            lib.Util.checkAndAddDirectory("save/archive/static");
            lib.Util.checkAndAddDirectory("save/archive/dynamic");
            lib.Util.checkAndAddDirectory("save/archive/players");

            clock = new lib.Clock(0);

            m_svcMgr = new svc.Mgr <svc.Service <msg.Msg>, msg.Msg>(m_cfg.res.mgrCfg, svc.SourceId.Local);
            svc.Base <svc.Service <msg.Msg>, msg.Msg> .setMgr(m_svcMgr);



            //*
            foreach (NetworkInterface nic in
                     NetworkInterface.GetAllNetworkInterfaces())
            {
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    log.logProps(nic, "Network Interface (up)", log.LogType.Info, prefix: "  ");
                }
                else
                {
                    log.info("Network Interface (down)");
                    log.info($"  {nic.Name} {nic.Description}");
                }

                foreach (UnicastIPAddressInformation addrInfo in
                         nic.GetIPProperties().UnicastAddresses)
                {
                    //log.logProps( addrInfo, " Addresses", log.LogType.Info, prefix: "    " );
                    log.debug($"    {addrInfo.Address}");
                }
            }
            //*/



            //string machineName = m_cfg.res.name; //+"/"+ep.Address.ToString() + ":" + ep.Port;

            //var machineName = new Shielded<string>(m_cfg.res.name);

            var machines = new List <IPEndPoint>();            // new Dictionary<string, IPEndPoint>();

            //machines[machineName] = new IPEndPoint( IPAddress.Any, m_cfg.res.port );

            /*
             * var localEndPoint = new IPEndPoint( IPAddress.Any, m_cfg.res.port );
             *
             *
             * foreach( var mac in m_cfg.res.machines )
             * {
             *      //var remoteName = $"remote_{mac.address}:{mac.port.ToString()}";
             *
             *      //machines[remoteName] = new IPEndPoint( IPAddress.Parse( mac.address ), mac.port );
             *
             *      machines.Add( new IPEndPoint( IPAddress.Parse( mac.address ), mac.port ) );
             * }
             */

            /* Shielded
             * connectToOtherMachines( machineName, localEndPoint, machines );
             *
             * var machineName_ver = machineName.SvcVersion( 0 );
             *
             * var key = $"name_{m_cfg.res.name}_{m_cfg.res.port.ToString()}";
             *
             * m_backend.Set( key, machineName_ver );
             *
             * //var test = machineVer.Value;
             *
             * Shielded.Shield.InTransaction( () => {
             *
             *      machineName.Value = "Hello";
             *
             *
             *      //machineName = "Hello";
             *
             *      //machineVer = machineVer.NextVersion();
             *
             *
             * } );
             */

            m_machines = m_machines.Add(new svc.Machine(m_cfg.res.machineCfg));


            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/

            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/

            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/

            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/

            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/

            /*
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * m_machines = m_machines.Add( new svc.Machine( m_cfg.res.machineCfg ) );
             * //*/


            foreach (var mac in m_machines)
            {
                m_svcMgr.start(mac);
            }


            m_svcMgr.startup();

            Thread.Sleep(1000);

            //*
            var startup = new msg.Startup {
            };

            var address = new RTAddress(m_svcMgr.Id, m_svcMgr.Id);

            foreach (var mac in m_machines)
            {
                m_svcMgr.send(address, startup, (svc) => svc.id == mac.id);
            }
            //*/
        }