예제 #1
0
            private StageActorRef.Receive Connecting(Outbound outbound)
            {
                return(args =>
                {
                    var sender = args.Item1;
                    var msg = args.Item2;

                    msg.Match()
                    .With <Terminated>(() => FailStage(new StreamTcpException("The IO manager actor (TCP) has terminated. Stopping now.")))
                    .With <Tcp.CommandFailed>(failed => FailStage(new StreamTcpException($"Tcp command {failed.Cmd} failed")))
                    .With <Tcp.Connected>(c =>
                    {
                        ((Outbound)_role).LocalAddressPromise.TrySetResult(c.LocalAddress);
                        _connection = sender;
                        SetHandler(_bytesOut, _readHandler);
                        StageActorRef.Unwatch(outbound.Manager);
                        StageActorRef.Become(Connected);
                        StageActorRef.Watch(_connection);
                        _connection.Tell(new Tcp.Register(StageActorRef, keepOpenonPeerClosed: true, useResumeWriting: false), StageActorRef);

                        if (IsAvailable(_bytesOut))
                        {
                            _connection.Tell(Tcp.ResumeReading.Instance, StageActorRef);
                        }

                        Pull(_bytesIn);
                    });
                });
            }
예제 #2
0
            private void TryUnbind()
            {
                if (_listener == null)
                {
                    return;
                }

                StageActorRef.Unwatch(_listener);
                SetKeepGoing(true);
                _listener.Tell(Tcp.Unbind.Instance, StageActorRef);
            }
예제 #3
0
 private void UnbindCompleted()
 {
     StageActorRef.Unwatch(_listener);
     if (_connectionFlowsAwaitingInitialization.Current == 0)
     {
         CompleteStage();
     }
     else
     {
         ScheduleOnce(BindShutdownTimer, _stage._bindShutdownTimeout);
     }
 }