Akka.Interfaced.SlimSocket.Server.TcpConnection.Open C# (CSharp) Метод

Open() публичный Метод

public Open ( ) : void
Результат void
        public void Open()
        {
            if (_isDisposed)
                throw new ObjectDisposedException(GetType().FullName);

            if (_isOpen)
                throw new InvalidOperationException("Already Opened");

            if (Settings == null)
                throw new InvalidOperationException("Settings");

            ProcessOpen();

            _isOpen = true;

            // 수신 시작

            var oldContext = SynchronizationContext.Current;
            SynchronizationContext.SetSynchronizationContext(null);
            try
            {
                IssueReceive();
            }
            finally
            {
                SynchronizationContext.SetSynchronizationContext(oldContext);
            }
        }

Usage Example

        protected override void PreStart()
        {
            base.PreStart();

            _self        = Self;
            _eventStream = Context.System.EventStream;

            // create initial actors and bind them

            if (_initiator.CreateInitialActors != null)
            {
                var actors = _initiator.CreateInitialActors(Context, _connection);
                if (actors != null)
                {
                    foreach (var actor in actors)
                    {
                        BindActor(actor.Item1, actor.Item2.Select(t => new BoundType(t)));
                    }
                }
            }

            // link connection to this

            _connection.Closed   += OnConnectionClose;
            _connection.Received += OnConnectionReceive;

            if (_connection.IsOpen == false)
            {
                try
                {
                    _connection.Open();
                }
                catch (Exception e)
                {
                    _logger.ErrorFormat("Cannot open connection.", e);
                }
            }
            else
            {
                if (_connection.Active)
                {
                    _connection.Send(new Packet
                    {
                        Type    = PacketType.System,
                        Message = "1",
                    });
                }
                else
                {
                    OnConnectionClose(_connection, -1);
                }
            }
        }
All Usage Examples Of Akka.Interfaced.SlimSocket.Server.TcpConnection::Open