예제 #1
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowDebug = false })
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageHandler>()
                .UsingHttpTransport()
                    .AsAServer("OtherSenderServer")
                    .AuthenticateToServer("ReceiverServer")
                        .WithRequest<AuthenticationRequest>()
                        .OnExpiry(s => Console.WriteLine("Session expired: {0}", s))
                .OpenChannel("OtherTestRequest")
                    .ForRequestReplySendingTo("TestReply@ReceiverServer")
                    .WithDurability()
                .Initialise();


            Console.WriteLine("I am the sender. Whats the password? (its 'Hello')");
            string password = Console.ReadLine();

            Bus.SendDirect(new AuthenticationRequest { Password = password }, new AuthenticationHandler(), exception => { });

            do
            {
                Console.WriteLine("I am the sender. Press enter to send messages..");
                Console.ReadLine();

                Console.WriteLine("Sending messages");

                Bus.Send(new TestMessage("Hello"));
            } while (true);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism {ShowInfo = false, ShowDebug = false})
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingHttpTransport()
                    .AsAServer("OtherSenderServer")
                .OpenDirectChannel("OtherTestRequest")
                    .ForRequestReplySendingTo("TestReply@ReceiverServer")
                .Initialise();

            do
            {
                Console.WriteLine("I am the other sender. Press enter to send messages..");
                Console.ReadLine();
                Console.WriteLine("Sending messages");

                Bus.SendDirect(new TestMessage("Hello"));
                Bus.SendDirect(new TestMessage("Hello1"));
                Bus.SendDirect(new TestMessage("Hello2"));
                Bus.SendDirect(new TestMessage("Hello3"));
                Bus.SendDirect(new TestMessage("Hello4"));
                Bus.SendDirect(new TestMessage("Hello5"));
                Bus.SendDirect(new TestMessage("Hello6"));
                Bus.SendDirect(new TestMessage("Hello7")); 
            }
            while (true);
        }
예제 #3
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowDebug = false })
                .UsingFilePersistence()
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageHandler>()
                .UsingHttpTransport()
                    .AsAServer("ReceiverServer")
                    .RequiresAuthentication()
                        .AcceptsRequest<AuthenticationRequest>()
                        .AuthenticatesOnReply<AuthenticatedResponse>()
                        .ExpiresAfter(TimeSpan.FromMinutes(1))
                        .OnExpiry(s => Console.WriteLine("Session expired: {0}", s))
                .OpenChannel("TestReply")
                    .ForRequestReplyReceiving()
                    .WithDurability()
                .Initialise();

            Console.WriteLine("I am the reciever. Press enter to exit");

            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism {ShowInfo = false, ShowDebug = false})
                .UsingFilePersistence()
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingHttpTransport()
                    .AsAServer("SenderServer")
                .OpenChannel("TestRequest")
                    .ForRequestReplySendingTo("TestReply@ReceiverServer")
                    .WithDurability()
                    .Sequenced()
                .Initialise();

            do
            {
                Console.WriteLine("I am the sender. Press enter to send messages..");
                Console.ReadLine();

                Console.WriteLine("Sending messages");

                for (int i = 0; i < 2001; i++) Bus.Send(new TestMessage("Hello" + i));
            }
            while (true);
        }
예제 #5
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowInfo = false })
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingFilePersistence()
                .UsingHttpTransport()
                    .AsAServer("Server")
                .OpenChannel("TestSenderA")
                    .ForRequestReplySendingTo("TestRecieverA@ServerA")
                    .OnlyForMessages().WithNamePattern("Channel1")
                    .WithDurability()
                    .Sequenced()
                .OpenChannel("TestSenderB")
                    .ForRequestReplySendingTo("TestRecieverB@ServerB")
                    .OnlyForMessages().WithNamePattern("Channel2")
                    .WithDurability()
                    .Sequenced()
                .Initialise();

            do
            {
                Console.WriteLine("I am the sender. Press A to send messages to reciever A, press B to send messages to reciever B..");
                ConsoleKeyInfo key = Console.ReadKey();

                if (key.Key == ConsoleKey.A)
                {
                    Console.WriteLine("Sending messages to GetChannel A");

                    Bus.Send(new Channel1Request("GetChannel A Hello"));
                    Bus.Send(new Channel1Request("GetChannel A Hello1"));
                    Bus.Send(new Channel1Request("GetChannel A Hello2"));
                    Bus.Send(new Channel1Request("GetChannel A Hello3"));
                    Bus.Send(new Channel1Request("GetChannel A Hello4"));
                    Bus.Send(new Channel1Request("GetChannel A Hello5"));
                    Bus.Send(new Channel1Request("GetChannel A Hello6"));
                    Bus.Send(new Channel1Request("GetChannel A Hello7"));
                }

                if (key.Key == ConsoleKey.B)
                {
                    Console.WriteLine("Sending messages to GetChannel B");

                    Bus.Send(new Channel2Request("GetChannel B Hello"));
                    Bus.Send(new Channel2Request("GetChannel B Hello1"));
                    Bus.Send(new Channel2Request("GetChannel B Hello2"));
                    Bus.Send(new Channel2Request("GetChannel B Hello3"));
                    Bus.Send(new Channel2Request("GetChannel B Hello4"));
                    Bus.Send(new Channel2Request("GetChannel B Hello5"));
                    Bus.Send(new Channel2Request("GetChannel B Hello6"));
                    Bus.Send(new Channel2Request("GetChannel B Hello7"));
                }
            }
            while (true);
        }
예제 #6
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param server="args">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs args)
        {
            var container = new IocContainer();

            container.RegisterInstance(() => new ObservableLoggingMechanism(new MainThreadDispatcher()) { ShowInfo = true, ShowDebug = true });
            container.RegisterFromAssemblyOf<ResponseHandler>();
            
            Configure.Messaging()
                .LoggingWith(container.Resolve<ObservableLoggingMechanism>())
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingFilePersistence()
                .UsingHttpTransport()
                    .AsAServerUsingAProxy("SenderServer")
                .OpenChannel("TestMetroRequest")
                    .ForRequestReplySendingTo("TestReply@ReceiverServer")
                    .HandleRepliesOnMainThread()
                    .WithDurability()
                    .Sequenced()
                .Initialise();

            ViewModelLocator.SetContainer(container);
            
            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create a Frame to act navigation context and navigate to the first page
            var rootFrame = new Frame();
            if (!rootFrame.Navigate(typeof(MainPage)))
            {
                throw new Exception("Failed to create initial page");
            }

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
예제 #7
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowDebug = false })
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingHttpTransport()
                    .AsAServer("ReceiverServer")
                .OpenDirectChannel("TestReply")
                    .ForRequestReplyReceiving()
                .Initialise();

            Console.WriteLine("I am the reciever. Press enter to exit");

            Console.ReadLine();
        }
예제 #8
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowInfo = false })
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingFilePersistence()
                .UsingHttpTransport()
                    .AsAServer("ServerB")
                .OpenChannel("TestRecieverB").ForRequestReplyReceiving()
                    .WithDurability()
                    .Sequenced()
                .Initialise();

            Console.WriteLine("I am reciever B");
            Console.ReadLine();                
        }
예제 #9
0
        static void Main(string[] args)
        {
            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Program>();

            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowInfo = false })
                .ResolveReferencesWith(container)
                .RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
                .UsingFilePersistence()
                .UsingHttpTransport()
                    .AsAServer("SubscriberServer")
                .OpenChannel("TestSubscriber")
                    .ForSubscribingTo("TestPublisher@ReceiverPublisherServer")
                .Initialise();
            
            Console.WriteLine("I am a subscriber, listening for messages..");

            Console.ReadLine();
        }
예제 #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var container = new IocContainer();
            container.RegisterFromAssemblyOf<Activity1>();

            MainActivityLocator.Set(this);
            
            Configure.Messaging()
                .LoggingWith(new ConsoleLoggingMechanism { ShowInfo = true, ShowDebug = false })
                .UsingSqlitePersistence()
                .ResolveReferencesWith(container)
                .UsingHttpTransport()
                    .AsAServerUsingAProxy("SenderServer")
                .OpenChannel("TestAndroidRequest")
                    .ForRequestReplySendingTo("TestReply@ReceiverServer")
                    .HandleRepliesOnMainThread()
                    .WithDurability()
                .Initialise();

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate
            {
                for (int i = 0; i < 20; i++)
                {
                    Bus.Send(new TestMessage { Text = string.Format("Message {0}", count) });
                    button.Text = string.Format("{0} messages sent!", count++);
                }
            };
        }
예제 #11
0
 static void AutoRegistrations(IocContainer ioc)
 {
     ioc.RegisterFromAssemblyOf<App>();
 }