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); }
/// <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); }
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(); }
public override void Start(EventFirer eventFirer) { HabboFigureFactory factory = CoreManager.ServerCore.HabboFigureFactory; factory .RegisterSet(typeof(Body180)); }
public ServerCore() { EventManager = new EventManager(); OfficalEventFirer = new EventFirer(null); StringLocale = new StringLocale(); PluginManager = new PluginManager(); GameSocketManagers = new Dictionary <string, GameSocketManager>(); }
public void FiringSimpleEventFiresToHandler() { var fired = false; var eventFirer = new EventFirer(); eventFirer.MySimpleEvent += (s, e) => { fired = true; }; eventFirer.OnMySimpleEvent(); fired.Should().BeTrue(); }
public void FiringEventFiresToHandler() { string result = null; var eventFirer = new EventFirer(); eventFirer.MyEvent += (s, e) => { result = e.Value; }; eventFirer.OnMyEvent("FooBar"); result.Should().Be("FooBar"); }
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); }
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(); }
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(); }
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"); }
/// <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); }
/// <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); }
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; }