예제 #1
0
        public Props Props()
        {
            PID SpawnRouterProcess(string name, Props props, PID parent)
            {
                var routerState = CreateRouterState();
                var wg          = new AutoResetEvent(false);


                var ctx        = new LocalContext(() => new RouterActor(this, routerState, wg), props.SupervisorStrategy, props.ReceiveMiddlewareChain, props.SenderMiddlewareChain, parent);
                var mailbox    = props.MailboxProducer();
                var dispatcher = props.Dispatcher;
                var process    = new RouterProcess(routerState, mailbox);

                var(self, absent) = ProcessRegistry.Instance.TryAdd(name, process);
                if (!absent)
                {
                    throw new ProcessNameExistException(name, self);
                }
                ctx.Self = self;
                mailbox.RegisterHandlers(ctx, dispatcher);
                mailbox.PostSystemMessage(Started.Instance);
                mailbox.Start();
                wg.WaitOne();
                return(self);
            }

            return(new Props().WithSpawner(SpawnRouterProcess));
        }
예제 #2
0
        public RouterSettings(RouterProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            this.BeginVertical();
            this.AddRow(new Label()
            {
                Text = Constants.ProcessNameLabel
            }, _name);
            this.AddRow(new Label()
            {
                Text = Constants.ProcessIdLabel
            }, _processId);
            this.EndVertical();


            GridView gv = new GridView();

            gv.DataStore = process.PortMappings;

            gv.Columns.Add(new GridColumn()
            {
                HeaderText = "Port Id",
                DataCell   = new TextBoxCell("PortId"),
                Editable   = true
            });
            gv.Columns.Add(new GridColumn()
            {
                HeaderText = "Network Number",
                DataCell   = new TextBoxCell("Network"),
                Editable   = true
            });

            this.BeginVertical();
            this.AddRow(gv);
            this.EndVertical();

            this.AddRow();
        }