Ejemplo n.º 1
0
        protected Task <string> Call(StationDesc func, string message)
        {
            var finished = _station.Grab(func).When(MsgType.Signal);

            _station.Send(MsgType.Link, message).To(func);
            return(finished);
        }
Ejemplo n.º 2
0
        public override void Start(string message, StationDesc src)
        {
            pinger = src;

            var grabPinger = Station.Grab(pinger);

            grabPinger.Signaled += handlePing;
            grabPinger.Blocked  += handleBlock;
        }
Ejemplo n.º 3
0
 private void _accept(string message, StationDesc src)
 {
     if (--_count < 1)
     {
         _station.Linked -= _accept;
         _station.Linked += _block;
     }
     Accepted(_station, message, src);
 }
Ejemplo n.º 4
0
        private async void handlePong(string msg, StationDesc src)
        {
            station.Log($"{msg} from {src.Name}");
            if (--cnt == 0)
            {
                await station.Send(MsgType.Block, "").To(ponger);

                station.Close();
                return;
            }
            ping();
        }
Ejemplo n.º 5
0
        protected sealed override async void Accepted(IStation station, string message, StationDesc src)
        {
            _station          = station;
            station.Signaled += (string msg, StationDesc _) =>
            {
                _tcs.TrySetResult(msg);
            };

            Next = src;

            var rst = await Invoked(message);

            await station.Send(MsgType.Signal, rst).To(Next);

            station.Close();
        }
Ejemplo n.º 6
0
 public Task Prepare(StationDesc destination, string message = "") => _station.Send(MsgType.Link, message).To(destination);
Ejemplo n.º 7
0
 public Runner(StationDesc next) : base(1)
 {
     Next = next;
     _tcs = new TaskCompletionSource <string>();
 }
Ejemplo n.º 8
0
 private void handleBlock(string msg, StationDesc src)
 {
     Station.Close();
 }
Ejemplo n.º 9
0
 private void handlePing(string msg, StationDesc src)
 {
     Station.Log($"{msg} from {src.Name}");
     pong();
 }
Ejemplo n.º 10
0
        protected sealed override async void Accepted(IStation station, string message, StationDesc src)
        {
            _station = station;

            string rst = await Invoked(message);

            await station.Send(MsgType.Signal, rst).To(src);

            station.Close();
        }
Ejemplo n.º 11
0
 private void _block(string message, StationDesc src)
 {
     _station.Send(MsgType.Block).To(src);
 }
Ejemplo n.º 12
0
 protected abstract void Accepted(IStation station, string message, StationDesc src);