コード例 #1
0
        public void MultilineLoop_WithNullLine_ThrowsArgumentNullException()
        {
            ILine line = null;
            ILoop loop = MakeLoop(100);

            var value = new MultilineLoop(line, loop);
        }
コード例 #2
0
 public App(IOutput output, IDispatcher dispatcher, ILogic logic, ILoop loop)
 {
     this.output     = output;
     this.dispatcher = dispatcher;
     this.logic      = logic;
     this.loop       = loop;
 }
コード例 #3
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();

            //Logger.Information("To get sure that u know how to work with this server, i've added this");
            //Logger.Information("Remove the lines located in the given file named by this log's prefix");
            //
            ////
            //Environment.Exit(-1);
            ////

            //ServerTime = TimeSpan.Zero;

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _serverlistManager = new ServerlistManager();
        }
コード例 #4
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();
            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new UnbanCommands())
            .Add(new UserkickCommand())
            //.Add(new UserkickCommand())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new ClanCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _serverlistManager = new ServerlistManager();
        }
コード例 #5
0
        public void MultilineLoop_WithNullLoop_ThrowsArgumentNullException()
        {
            ILine line = new Line("10", MakeStatement());
            ILoop loop = null;

            var value = new MultilineLoop(line, loop);
        }
コード例 #6
0
        public APIServer()
            : base(new APISessionFactory(), ArrayPool <byte> .Create(1 * 1024 * 1024, 10), 10)
        {
            Pipeline.AddFirst("rmi", new SimpleRmiPipe())
            .AddService(new ServerlistService());

            _worker = new TaskLoop(Config.Instance.API.Timeout, Worker);
        }
コード例 #7
0
        protected override void OnTick()
        {
            base.OnTick();

            ILoop loop = (ILoop)m_gameServer;

            loop.Update();
        }
コード例 #8
0
        public ServerlistManager()
        {
            _client = new TcpClient(new SessionFactory(), ArrayPool <byte> .Shared);
            _client.Pipeline.AddFirst("rmi", new SimpleRmiPipe());
            _worker = new TaskLoop(Config.Instance.AuthAPI.UpdateInterval, Worker);

            _client.Connected    += Client_Connected;
            _client.Disconnected += Client_Disconnected;
        }
コード例 #9
0
 public ActiveObject(ILoopsFactory factory, Action <T> action,
                     int capacity,
                     TimeSpan interval = new TimeSpan())
 {
     _loop     = factory.Create(LoopAction, interval);
     _queue    = new BlockingCollection <Message>(new ConcurrentQueue <Message>());
     _action   = action;
     _capacity = capacity;
     _interval = interval;
 }
コード例 #10
0
        public void IsOver_AtStart_IsFalse()
        {
            const int countOfIterations = 2;
            ILine     line = new Line("10", MakeStatement());
            ILoop     loop = MakeLoop(countOfIterations);

            var value = new MultilineLoop(line, loop);

            Assert.IsFalse(value.IsOver);
        }
コード例 #11
0
        public void SetNextLoop()
        {
            iLoop = iLoop.GetNext();

            if (Library.Current.IsForeground)
            {
                BackgroundCommunicator.SendLoop(this);
                UpdateLoopIcon();
            }
        }
コード例 #12
0
 public InteractiveLoop(IConsole console, IConsoleKeyHandler consoleKeyHandler, IConsoleWriter consoleWriter,
                        IReplEngine replEngine, ILoop loop, IConsoleState consoleState)
 {
     _console           = console;
     _consoleKeyHandler = consoleKeyHandler;
     _consoleWriter     = consoleWriter;
     _replEngine        = replEngine;
     _loop         = loop;
     _consoleState = consoleState;
 }
コード例 #13
0
 public void Dispose()
 {
     if (_loop != null)
     {
         Stop();
         _queue = null;
         _loop.Dispose();
         _loop   = null;
         _action = null;
     }
 }
コード例 #14
0
        public void IsOver_AtEnd_IsTrue()
        {
            const int countOfIterations = 2;
            ILine     line = new Line("10", MakeStatement());
            ILoop     loop = MakeLoop(countOfIterations);

            var value = new MultilineLoop(line, loop);

            // Take two iterations of the loop:
            value.TakeStep();
            value.TakeStep();

            Assert.IsTrue(value.IsOver);
        }
コード例 #15
0
        /// <summary>
        /// Starts the loop.
        /// </summary>
        /// <param name="loop">The loop to repeated running.</param>
        /// <returns><c>true</c> if new loop started, <c>false</c> if the loop is already started.</returns>
        public void StartLoop(ILoop loop)
        {
            ThrowIfDisposed();
            ThrowIfNotRunning();

            if (loop == null)
            {
                throw new ArgumentNullException(nameof(loop));
            }

            var multilineLoop = new MultilineLoop(Runner.RunningLine, loop);

            StackOfLoops.Push(multilineLoop);
        }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultilineLoop"/> with the start line number and the decorated loop.
        /// </summary>
        /// <param name="startLine">The start line of the multiline loop.</param>
        /// <param name="loop">The decorated loop.</param>
        public MultilineLoop(ILine startLine, ILoop loop)
        {
            if (startLine == null)
            {
                throw new ArgumentNullException("startLine");
            }

            if (loop == null)
            {
                throw new ArgumentNullException("loop");
            }

            StartLine     = startLine;
            DecoratedLoop = loop;
        }
コード例 #17
0
        public static void Signal(ILoop loop, double time, double dt, ISignalGenerator signalGenerator, SimulateCallback callback = null)
        {
            loop.Initialize(dt);
            callback?.Invoke(0, 0d);

            int iterations = (int)Math.Floor(time / dt) + 1;

            for (int i = 1; i < iterations; i++)
            {
                double currentTime  = i * dt;
                var    signalSample = signalGenerator.GetSample(currentTime);
                loop.NextIteration(signalSample.value, currentTime, dt);

                callback?.Invoke(i, currentTime);
            }
        }
コード例 #18
0
        public ServerlistMgr()
        {
            var handler = new Handler();

            handler.Connected    += Client_Connected;
            handler.Disconnected += Client_Disconnected;

            _eventLoopGroup = new MultithreadEventLoopGroup(1);
            _bootstrap      = new Bootstrap()
                              .Group(_eventLoopGroup)
                              .Channel <TcpSocketChannel>()
                              .Handler(new ActionChannelInitializer <IChannel>(ch =>
            {
                ch.Pipeline.AddLast(new SimpleRmiHandler())
                .AddLast(handler);
            }));
            _worker = new TaskLoop(TimeSpan.FromSeconds(5), Worker);
        }
コード例 #19
0
        public ServerlistManager()
        {
            var handler = new Handler();

            handler.Connected    += Client_Connected;
            handler.Disconnected += Client_Disconnected;

            _eventLoopGroup = new MultithreadEventLoopGroup(1);
            _bootstrap      = new Bootstrap()
                              .Group(_eventLoopGroup)
                              .Channel <TcpSocketChannel>()
                              .Handler(new ActionChannelInitializer <IChannel>(ch =>
            {
                ch.Pipeline.AddLast(new SimpleRmiHandler())
                .AddLast(handler);
            }));
            _worker = new TaskLoop(Config.Instance.AuthAPI.UpdateInterval, Worker);
        }
コード例 #20
0
        public override void Compile(ByteCode bc)
        {
            using (bc.EnterSource(m_Ref))
            {
                if (bc.LoopTracker.Loops.Count == 0)
                {
                    throw new SyntaxErrorException("<break> not inside a loop");
                }

                ILoop loop = bc.LoopTracker.Loops.Peek();

                if (loop.IsBoundary())
                {
                    throw new SyntaxErrorException("<break> not inside a loop");
                }

                loop.CompileBreak(bc);
            }
        }
コード例 #21
0
        protected override void OnAfterStop()
        {
            base.OnAfterStop();

            ILoop loop = (ILoop)m_gameServer;

            loop.Destroy();

            m_gameServer.LoggedIn         -= OnLoggedIn;
            m_gameServer.LoggedOff        -= OnLoggedOff;
            m_gameServer.RoomsListChanged -= OnRoomsListChanged;
            m_gameServer.JoinedRoom       -= OnJoinRoom;
            m_gameServer.LeftRoom         -= OnLeftRoom;
            m_gameServer.RoomDestroyed    -= OnRoomDestoryed;
            m_gameServer.ReadyToLaunch    -= OnReadyToLaunch;
            m_gameServer.Launched         -= OnLaunched;
            m_gameServer.ChatMessage      -= OnChatMessage;
            m_gameServer = null;
        }
コード例 #22
0
ファイル: BreakStatement.cs プロジェクト: amseet/Orion
        public override void Compile(ByteCode bc)
        {
            using (bc.EnterSource(m_Ref))
            {
                if (bc.LoopTracker.Loops.Count == 0)
                {
                    throw new SyntaxErrorException(this.Script, m_Ref, "<break> at line {0} not inside a loop", m_Ref.FromLine);
                }

                ILoop loop = bc.LoopTracker.Loops.Peek();

                if (loop.IsBoundary())
                {
                    throw new SyntaxErrorException(this.Script, m_Ref, "<break> at line {0} not inside a loop", m_Ref.FromLine);
                }

                loop.CompileBreak(bc);
            }
        }
コード例 #23
0
ファイル: AuthServer.cs プロジェクト: Salcoj/NetspherePirates
        private AuthServer()
            : base(new ProudSessionFactory(), ArrayPool <byte> .Create(1 * 1024 * 1024, Config.Instance.MaxConnections), Config.Instance.MaxConnections)
        {
            var config      = new ProudConfig(new Guid("{9be73c0b-3b10-403e-be7d-9f222702a38c}"));
            var proudFilter = new ProudServerPipe(config);

#if DEBUG
            proudFilter.UnhandledProudCoreMessage += OnUnhandledProudCoreMessage;
            proudFilter.UnhandledProudMessage     += OnUnhandledProudMessage;
#endif
            Pipeline.AddFirst("proudnet", proudFilter);
            Pipeline.AddLast("s4_protocol", new NetspherePipe(new AuthMessageFactory()));
            Pipeline.AddLast("s4_service", new MessageHandlerPipe())
            .Add(new AuthService())
            .UnhandledMessage += OnUnhandledMessage;

            _worker       = new TaskLoop(TimeSpan.FromSeconds(10), Worker);
            ServerManager = new ServerManager();
        }
コード例 #24
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();

            //ServerTime = TimeSpan.Zero;

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), (Action <TimeSpan>)Worker);
            _serverlistManager = new ServerlistManager();
        }
コード例 #25
0
        protected override void OnBeforeRun()
        {
            base.OnBeforeRun();

            m_gameServer = new GameServerImpl(m_path, m_matchServerUrl);

            ILoop loop = (ILoop)m_gameServer;

            loop.Start(this);

            m_gameServer.LoggedIn         += OnLoggedIn;
            m_gameServer.LoggedOff        += OnLoggedOff;
            m_gameServer.RoomsListChanged += OnRoomsListChanged;
            m_gameServer.JoinedRoom       += OnJoinRoom;
            m_gameServer.LeftRoom         += OnLeftRoom;
            m_gameServer.RoomDestroyed    += OnRoomDestoryed;
            m_gameServer.ReadyToLaunch    += OnReadyToLaunch;
            m_gameServer.Launched         += OnLaunched;
            m_gameServer.ChatMessage      += OnChatMessage;
        }
コード例 #26
0
        protected override void OnAfterStop()
        {
            base.OnAfterStop();

            if (m_matchServer != null)
            {
                m_matchServer.Tick           -= OnTick;
                m_matchServer.ReadyToPlayAll -= OnReadyToPlayAll;
                m_matchServer.Paused         -= OnPaused;
                m_matchServer.Ping           -= OnPing;
                m_matchServer.ChatMessage    -= OnChatMessage;
                m_matchServer = null;
            }

            if (m_gameLoop != null)
            {
                m_gameLoop.Destroy();
                m_gameLoop = null;
            }
        }
コード例 #27
0
        /// <summary>
        /// Starts a Loop Server and prepares the process to connect to Olive Helps.
        /// </summary>
        /// <remarks>
        /// Only one Loop can be run per process.
        /// </remarks>
        /// <param name="loop">The Loop you're running.</param>
        /// <param name="logger">The Logger you're using.</param>
        public static void Start(ILoop loop, ILogger logger)
        {
            var loopServer = new LoopServer(loop, logger);
            var server     = new Server
            {
                Services =
                {
                    Loop.BindService(loopServer),
                    GRPCBroker.BindService(loopServer._brokerServer),
                    GRPCStdio.BindService(new StdioServer())
                },
                Ports = { new ServerPort("localhost", 0, ServerCredentials.Insecure) }
            };

            server.Start();
            var currentPort = server.Ports.First();

            Console.Out.WriteLine($"1|1|tcp|127.0.0.1:{currentPort.BoundPort}|grpc");
            System.Diagnostics.Process.GetCurrentProcess().WaitForExit();
        }
コード例 #28
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();
            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new UnbanCommands())
            .Add(new UserkickCommand())
            .Add(new KickCommand())
            .Add(new AllkickCommand())
            .Add(new RoomkickCommand())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new WholeNoticeCommand())
            .Add(new ClanCommands())
            .Add(new InventoryCommands())
            .Add(new SearchCommand())
            .Add(new CommandWrapper())
            .Add(new HelpCommand());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker       = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _worker2      = new ThreadLoop(TimeSpan.FromSeconds(1), Worker2);
            _workerDelta  = new AccurateDelta(TimeSpan.Zero);
            _worker2Delta = new AccurateDelta(TimeSpan.Zero);

            _serverlistManager = new ServerlistMgr();
            AverageWorkerDelta.Enqueue(0);
            HighWorkerDelta.TryAdd(0, 0);
        }
コード例 #29
0
        protected override void OnTick()
        {
            base.OnTick();

            if (m_gameLoop != null)
            {
                m_gameLoop.Update();
            }
            else
            {
                if (m_matchServer != null)
                {
                    const int WaitSeconds = 5;
                    if (Time > WaitSeconds)
                    {
                        m_gameLoop = (ILoop)m_matchServer;
                        if (!m_gameLoop.Start(this))
                        {
                            m_gameLoop = null;
                        }
                    }
                }
            }
        }
コード例 #30
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.UsageScenario_SenarioBehaviour == null))
                {
                    IUsageScenario usageScenario_SenarioBehaviourCasted = item.As <IUsageScenario>();
                    if ((usageScenario_SenarioBehaviourCasted != null))
                    {
                        this._parent.UsageScenario_SenarioBehaviour = usageScenario_SenarioBehaviourCasted;
                        return;
                    }
                }
                if ((this._parent.BranchTransition_ScenarioBehaviour == null))
                {
                    IBranchTransition branchTransition_ScenarioBehaviourCasted = item.As <IBranchTransition>();
                    if ((branchTransition_ScenarioBehaviourCasted != null))
                    {
                        this._parent.BranchTransition_ScenarioBehaviour = branchTransition_ScenarioBehaviourCasted;
                        return;
                    }
                }
                if ((this._parent.Loop_ScenarioBehaviour == null))
                {
                    ILoop loop_ScenarioBehaviourCasted = item.As <ILoop>();
                    if ((loop_ScenarioBehaviourCasted != null))
                    {
                        this._parent.Loop_ScenarioBehaviour = loop_ScenarioBehaviourCasted;
                        return;
                    }
                }
                IAbstractUserAction actions_ScenarioBehaviourCasted = item.As <IAbstractUserAction>();

                if ((actions_ScenarioBehaviourCasted != null))
                {
                    this._parent.Actions_ScenarioBehaviour.Add(actions_ScenarioBehaviourCasted);
                }
            }