Example #1
0
        void MessageBus_ClientAddedEvent(MessageBus.Core.IMessageBus messageBus, ClientId clientId)
        {// Once a new client has been added, we want to subscribe to its event.
            // Do the report on an invoke thread, since this message bus system event is raised on a non UI thread.
            this.Invoke(new GeneralHelper.GenericDelegate <string>(Report), "Subscribing client " + clientId.ToString());

            // We could also do a full subscribe like this _poolClient.Subscribe<ICommunicationInterface>()
            // but since this only works on local components (attached to this super pool instance) and not
            // ones that are remoted (TCP), we need to subscribe to each one separately.
            _poolClient.Subscribe <ICommunicationInterface>(clientId).EventOne += new HelperDelegate(FormServer_EventOne);
        }
Example #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Text += " - " + this.ClientName;

            // The steps here are exactly the same, as in server side, only difference is the ClientMessageBus
            // instead of ServerMessageBus. Since this is the only difference, all the remaining source code
            // is completely independent of whether its a server or a client side.

            //// Assign the default tracer, to provide system wide tracing functionality.
            //SystemMonitor.AssignTracer(new Tracer());
            //this.tracerControl1.Tracer = SystemMonitor.Tracer;

            IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, ServerMessageBus.DefaultPort);

            // Create the underlying (client) message bus, that takes care of transporting the
            // actual communication messages; the message bus TCP communication is created
            // at default port, at localhost.
            ClientMessageBus messageBus = new ClientMessageBus(endPoint, this.ClientName, null);

            // Initialize the super pool with this message bus.
            _pool = new Matrix.Framework.SuperPool.Core.SuperPool(messageBus);

            // Create the client that will server as a connection between this
            // class and the super pool and add the client to the pool.
            _poolClient = new SuperPoolClient("Client." + this.ClientName, this);
            _pool.AddClient(_poolClient);

            messageBus.ClientAddedEvent += (bus, id) =>
            {
                this.Invoke(new GeneralHelper.GenericDelegate <string>(Report),
                            "Client added " + id.ToString());
                _poolClient.Subscribe <ICommunicationInterface>(id).EventOne += new HelperDelegate(FormServer_EventOne);
            };
            messageBus.ClientRemovedEvent += (bus, id, remove) =>
            {
                this.Invoke(new GeneralHelper.GenericDelegate <string>(Report),
                            "Client removed " + id.ToString());
            };
            // Use this to assign a specific execution strategy to a given client.
            // _poolClient.SetupExecutionStrategy(new FrameworkThreadPoolExecutionStrategy());
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Text += " - " + this.ClientName;

            // The steps here are exactly the same, as in server side, only difference is the ClientMessageBus
            // instead of ServerMessageBus. Since this is the only difference, all the remaining source code
            // is completely independent of whether its a server or a client side.

            //// Assign the default tracer, to provide system wide tracing functionality.
            //SystemMonitor.AssignTracer(new Tracer());
            //this.tracerControl1.Tracer = SystemMonitor.Tracer;

            IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, ServerMessageBus.DefaultPort);

            // Create the underlying (client) message bus, that takes care of transporting the
            // actual communication messages; the message bus TCP communication is created
            // at default port, at localhost.
            ClientMessageBus messageBus = new ClientMessageBus(endPoint, this.ClientName, null);

            // Initialize the super pool with this message bus.
            _pool = new Matrix.Framework.SuperPool.Core.SuperPool(messageBus);

            // Create the client that will server as a connection between this
            // class and the super pool and add the client to the pool.
            _poolClient = new SuperPoolClient("Client." + this.ClientName, this);
            _pool.AddClient(_poolClient);

            messageBus.ClientAddedEvent += (bus, id) =>
                                               {
                                                   this.Invoke(new GeneralHelper.GenericDelegate<string>(Report),
                                                               "Client added " + id.ToString());
                                                   _poolClient.Subscribe<ICommunicationInterface>(id).EventOne += new HelperDelegate(FormServer_EventOne);
                                               };
            messageBus.ClientRemovedEvent += (bus, id, remove) =>
                                                 {
                                                     this.Invoke(new GeneralHelper.GenericDelegate<string>(Report),
                                                                 "Client removed " + id.ToString());
                                                 };
            // Use this to assign a specific execution strategy to a given client.
            // _poolClient.SetupExecutionStrategy(new FrameworkThreadPoolExecutionStrategy());
        }