コード例 #1
0
 /// <summary>
 ///     Invoked when a node's connection to this server has been disconnected
 /// </summary>
 /// <param name="closedChannel">The <see cref="IConnection" /> instance that just closed</param>
 /// <param name="reason">The reason why this node disconnected</param>
 protected void NodeDisconnected(HeliosConnectionException reason, IConnection closedChannel)
 {
     if (EventLoop.Disconnection != null)
     {
         EventLoop.Disconnection(reason, closedChannel);
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: ststeiger/akka.net
 public void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
 {
     _log.Debug("disconnected from {0}", closedChannel.RemoteHost);
     _fsm.Tell(PoisonPill.Instance);
     //TODO: Some logic here in JVM version to execute this on a different pool to the Netty IO pool
     RemoteConnection.Shutdown(closedChannel);
 }
コード例 #3
0
 protected void InvokeDisconnectIfNotNull(INode remoteHost, HeliosConnectionException ex)
 {
     if (NetworkEventLoop.Disconnection != null)
     {
         NetworkEventLoop.Disconnection(ex, this);
     }
 }
コード例 #4
0
ファイル: HeliosHelpers.cs プロジェクト: zhanjian/akka.net
 protected void InvokeDisconnectIfNotNull(INode remoteHost, HeliosConnectionException ex)
 {
     if (OnDisconnection != null)
     {
         OnDisconnection(ex, this);
     }
 }
コード例 #5
0
 /// <summary>
 /// Handles an abrupt termination of the connection
 /// </summary>
 /// <param name="heliosConnectionException"></param>
 /// <param name="connection"></param>
 private void ConnectionTerminated(HeliosConnectionException heliosConnectionException, IConnection connection)
 {
     // Server has gone offline, go and die too
     log.FatalFormat("Server went offline. Reason: {0}", heliosConnectionException.Type);
     Connection.Client.Close();
     Environment.Exit(1);
 }
コード例 #6
0
        /// <summary>
        /// Fires whenever a Helios <see cref="IConnection"/> gets closed.
        ///
        /// Two possible causes for this event handler to fire:
        ///  * The other end of the connection has closed. We don't make any distinctions between graceful / unplanned shutdown.
        ///  * This end of the connection experienced an error.
        /// </summary>
        /// <param name="cause">An exception describing why the socket was closed.</param>
        /// <param name="closedChannel">The handle to the socket channel that closed.</param>
        protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
        {
            //if (cause != null)
            //    ChannelLocalActor.Notify(closedChannel, new UnderlyingTransportError(cause, "Underlying transport closed."));

            ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Unknown));
            ChannelLocalActor.Remove(closedChannel);
        }
コード例 #7
0
ファイル: TcpConnection.cs プロジェクト: mortezasoft/helios
        public override void Open()
        {
            CheckWasDisposed();

            if (IsOpen())
            {
                return;
            }

            if (RemoteHost == null || RemoteHost.Host == null)
            {
                throw new HeliosConnectionException(ExceptionType.NotOpen,
                                                    "Cannot open a connection to a null Node or null Node.Host");
            }

            if (RemoteHost.Port <= 0)
            {
                throw new HeliosConnectionException(ExceptionType.NotOpen, "Cannot open a connection to an invalid port");
            }

            if (_client == null)
            {
                InitClient();
            }

            var ar = _client.BeginConnect(RemoteHost.Host, RemoteHost.Port, null, null);

            if (ar.AsyncWaitHandle.WaitOne(Timeout))
            {
                try
                {
                    _client.EndConnect(ar);
                    HeliosTrace.Instance.TcpClientConnectSuccess();
                }
                catch (SocketException ex)
                {
                    HeliosTrace.Instance.TcpClientConnectFailure(ex.Message);
                    // JKH = because I want to know if my BeginConnect has failed and because when I use BeginConnect I cannot catch this throw and it litters my Debug window
                    var rethrow = new HeliosConnectionException(ExceptionType.NotOpen, ex);
                    InvokeDisconnectIfNotNull(RemoteHost, rethrow);
                    return;
                    //throw rethrow;	using BeginConnect, I cannot catch this throw...
                }
            }
            else
            {
                _client.Close();
                HeliosTrace.Instance.TcpClientConnectFailure("Timed out on connect");
                // JKH = because I want to know if my BeginConnect has failed
                var rethrow = new HeliosConnectionException(ExceptionType.TimedOut, "Timed out on connect");
                InvokeDisconnectIfNotNull(RemoteHost, rethrow);
                throw rethrow;
            }
            SetLocal(_client);
            InvokeConnectIfNotNull(RemoteHost);
        }
コード例 #8
0
        public void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
        {
            _log.Debug("disconnect from {0}", closedChannel.RemoteHost);
            var fsm = _clients[closedChannel];

            fsm.Tell(new Controller.ClientDisconnected(new RoleName(null)));
            ActorRef removedActor;

            _clients.TryRemove(closedChannel, out removedActor);
        }
コード例 #9
0
ファイル: Entry.cs プロジェクト: erynet/SensorMonitor
 private void ConnectionTerminatedCallback(HeliosConnectionException reason, IConnection closedChannel)
 {
     //Invoke((Action)(() =>
     //{
     //    AppendStatusText(string.Format("Disconnected from {0}", closedChannel.RemoteHost));
     //    AppendStatusText(string.Format("Reason: {0}", reason.Message));
     //    tsStatusLabel.Text = string.Format("Disconnected from {0}", closedChannel.RemoteHost);
     //    btnSend.Enabled = false;
     //    tbSend.Enabled = false;
     //}));
 }
コード例 #10
0
        protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
        {
            if (cause != null)
            {
                ChannelLocalActor.Notify(closedChannel, new UnderlyingTransportError(cause, "Underlying transport closed."));
            }
            if (cause != null && cause.Type == ExceptionType.Closed)
            {
                ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Shutdown));
            }
            else
            {
                ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Unknown));
            }

            ChannelLocalActor.Remove(closedChannel);
        }
コード例 #11
0
ファイル: RemoteConnection.cs プロジェクト: zhanjian/akka.net
 protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
 {
     _handler.OnDisconnect(cause, closedChannel);
 }
コード例 #12
0
 private void ConnectionTerminatedCallback(HeliosConnectionException reason, IConnection closedChannel)
 {
     //log
 }
コード例 #13
0
 protected abstract void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel);
コード例 #14
0
 protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
 {
     ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Unknown));
 }
コード例 #15
0
 private void ConnectionTerminatedCallback(HeliosConnectionException reason, IConnection closedchannel)
 {
     Terminated?.Invoke(reason, closedchannel);
 }