AspComet.Samples.Chat.Global.Application_Start C# (CSharp) Method

Application_Start() protected method

protected Application_Start ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected void Application_Start(object sender, EventArgs e)
        {
            //-------------------------------------------------------------------------------------------------
            //   There are two ways to initialise AspComet.  The simple way to do this is:
            // Setup.AspComet.InANonExtensibleAndNonConfigurableManner();
            //
            //   However, in any application of any size, you will want to configure AspComet using the common
            //   service locator backed onto your application's IoC container.
            // Configuration.InitialiseHttpHandler.WithMessageBus(messageBus);
            //
            //-------------------------------------------------------------------------------------------------

            SetupIoCContainer();

            ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(container));

            EventHub.Subscribe<HandshakingEvent>(container.Resolve<HandshakeAuthenticator>().CheckHandshake);
            EventHub.Subscribe<PublishingEvent>(container.Resolve<BadLanguageBlocker>().CheckMessage);
            EventHub.Subscribe<SubscribingEvent>(container.Resolve<SubscriptionChecker>().CheckSubscription);
            EventHub.Subscribe<PublishingEvent>("/service/whisper", container.Resolve<Whisperer>().SendWhisper);
        }