예제 #1
0
        public async Task SimpleEventHoldsWeakReference()
        {
            var eventFirer = new EventFirer();

            WeakReference reference;

            {
                var handler = new Handler <EventArgs>();
                reference = new WeakReference(handler);

                eventFirer.MySimpleEvent += handler.HandleEvent;
                eventFirer.OnMySimpleEvent();
            }

            var pos = 0;

            while (reference.Target != null && pos < 10)
            {
                await Task.Delay(1000);

                GC.Collect();
                GC.WaitForPendingFinalizers();

                eventFirer.OnMyEvent("HelloWorld");

                pos++;
            }

            reference.Target.Should().BeNull();

            GC.KeepAlive(eventFirer);
        }
예제 #2
0
        /// <summary>
        ///   Called when the plugin is started.
        /// </summary>
        public override void Start(EventFirer eventFirer)
        {
            EventFirer = eventFirer;

            MessengerManager = new MessengerManager(this);
            ExtensionMethods.RegisterPluginInstance(CoreManager.ServerCore, this);
        }
예제 #3
0
        public async Task UsingWeakEventManagerDoesntKeepAlive()
        {
            WeakReference reference;

            {
                var eventFirer = new EventFirer();
                reference = new WeakReference(eventFirer);

                var handler = new Handler <EventArgs>();
                eventFirer.MySimpleEvent += handler.HandleEvent;
            }

            var pos = 0;

            while (reference.Target != null && pos < 10)
            {
                await Task.Delay(1000);

                GC.Collect();
                GC.WaitForPendingFinalizers();

                pos++;
            }

            reference.Target.Should().BeNull();
        }
예제 #4
0
        public override void Start(EventFirer eventFirer)
        {
            HabboFigureFactory factory = CoreManager.ServerCore.HabboFigureFactory;

            factory
            .RegisterSet(typeof(Body180));
        }
예제 #5
0
        public ServerCore()
        {
            EventManager      = new EventManager();
            OfficalEventFirer = new EventFirer(null);

            StringLocale       = new StringLocale();
            PluginManager      = new PluginManager();
            GameSocketManagers = new Dictionary <string, GameSocketManager>();
        }
예제 #6
0
        public void FiringSimpleEventFiresToHandler()
        {
            var fired = false;

            var eventFirer = new EventFirer();

            eventFirer.MySimpleEvent += (s, e) => { fired = true; };
            eventFirer.OnMySimpleEvent();

            fired.Should().BeTrue();
        }
예제 #7
0
        public void FiringEventFiresToHandler()
        {
            string result = null;

            var eventFirer = new EventFirer();

            eventFirer.MyEvent += (s, e) => { result = e.Value; };
            eventFirer.OnMyEvent("FooBar");

            result.Should().Be("FooBar");
        }
예제 #8
0
        private void SendFuserights(HabboEventArgs eventArgs)
        {
            FuserightEventArgs fuserightEventArgsInstance = new FuserightEventArgs(eventArgs.Habbo);

            EventFirer.Fire("fuseright_request:before", eventArgs);
            EventFirer.Fire("fuseright_request:after", eventArgs);

            new MFuseRights
            {
                FuseRights = fuserightEventArgsInstance.GetFuserights()
            }.Send(eventArgs.Habbo);
        }
예제 #9
0
        public void FiringRemovedSimpleEventDoesntFireToHandler()
        {
            var fired = false;

            var          eventFirer = new EventFirer();
            EventHandler handler    = (sender, args) => fired = true;

            eventFirer.MySimpleEvent += handler;
            eventFirer.MySimpleEvent -= handler;
            eventFirer.OnMyEvent("FooBar");

            fired.Should().BeFalse();
        }
예제 #10
0
        public void FiringRemovedEventDoesntFireToHandler()
        {
            string result = null;

            var eventFirer = new EventFirer();
            EventHandler <EventArgs <string> > handler = (sender, args) => result = args.Value;

            eventFirer.MyEvent += handler;
            eventFirer.MyEvent -= handler;
            eventFirer.OnMyEvent("FooBar");

            result.Should().BeNull();
        }
예제 #11
0
        public void FiringEventFiresToMultipleHandlers()
        {
            string result1 = null;
            string result2 = null;

            var eventFirer = new EventFirer();

            eventFirer.MyEvent += (s, e) => { result1 = e.Value; };
            eventFirer.MyEvent += (s, e) => { result2 = e.Value; };
            eventFirer.OnMyEvent("FooBar");

            result1.Should().Be("FooBar");
            result2.Should().Be("FooBar");
        }
예제 #12
0
        /// <summary>
        ///   Called when the plugin is started.
        /// </summary>
        public override void Start(EventFirer eventFirer)
        {
            EventFirer = eventFirer;

            IPAddress ipAddress = CoreManager.ServerCore.Config.GetValue("r36:bindip", IPAddress.Any).Value;
            ushort port = CoreManager.ServerCore.Config.GetValue<ushort>("r36:bindport", 14478).Value;

            GameSocketProtocol r36Protocol = new GameSocketProtocol(new ClassicGameSocketReader(), 36);

            GameSocketManager = CoreManager.ServerCore.NewGameSocketManager("R36", ipAddress, port, r36Protocol);
            GameSocketManager.Start();

            CoreManager.ServerCore.EventManager.StrongBind<GameSocketEventArgs>("incoming_game_connection:after", AcceptConnection);
            CoreManager.ServerCore.EventManager.WeakBind<GameSocketEventArgs>("incoming_game_connection:after", RegisterLoginHandlers);
            CoreManager.ServerCore.EventManager.WeakBind<HabboEventArgs>("habbo_login:after", ConfirmLogin);
            CoreManager.ServerCore.EventManager.WeakBind<HabboEventArgs>("habbo_login:after", SendFuserights);
        }
예제 #13
0
        /// <summary>
        ///   Called when the plugin is started.
        /// </summary>
        public override void Start(EventFirer eventFirer)
        {
            EventFirer = eventFirer;

            IPAddress ipAddress = CoreManager.ServerCore.Config.GetValue("r36:bindip", IPAddress.Any).Value;
            ushort    port      = CoreManager.ServerCore.Config.GetValue <ushort>("r36:bindport", 14478).Value;

            GameSocketProtocol r36Protocol = new GameSocketProtocol(new ClassicGameSocketReader(), 36);

            GameSocketManager = CoreManager.ServerCore.NewGameSocketManager("R36", ipAddress, port, r36Protocol);
            GameSocketManager.Start();


            CoreManager.ServerCore.EventManager.StrongBind <GameSocketEventArgs>("incoming_game_connection:after", AcceptConnection);
            CoreManager.ServerCore.EventManager.WeakBind <GameSocketEventArgs>("incoming_game_connection:after", RegisterLoginHandlers);
            CoreManager.ServerCore.EventManager.WeakBind <HabboEventArgs>("habbo_login:after", ConfirmLogin);
            CoreManager.ServerCore.EventManager.WeakBind <HabboEventArgs>("habbo_login:after", SendFuserights);
        }
예제 #14
0
        public override void Start(EventFirer eventFirer)
        {
            HabboFigureFactory factory = CoreManager.ServerCore.HabboFigureFactory;

            factory.RegisterSet(typeof(Body180));
        }
        /// <summary>
        ///   Called when the plugin is started.
        /// </summary>
        public override void Start(EventFirer eventFirer)
        {
            EventFirer = eventFirer;

            // Here would be a good place to start...
        }
 /// <summary>
 ///   Called when the plugin is started.
 /// </summary>
 public override void Start(EventFirer eventFirer)
 {
     EventFirer = eventFirer;
     ConsoleLayout = new Layout(this).ConsoleLayout;
 }