/// <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); } }
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); }
protected void InvokeDisconnectIfNotNull(INode remoteHost, HeliosConnectionException ex) { if (NetworkEventLoop.Disconnection != null) { NetworkEventLoop.Disconnection(ex, this); } }
protected void InvokeDisconnectIfNotNull(INode remoteHost, HeliosConnectionException ex) { if (OnDisconnection != null) { OnDisconnection(ex, this); } }
/// <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); }
/// <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); }
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); }
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); }
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; //})); }
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); }
protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel) { _handler.OnDisconnect(cause, closedChannel); }
private void ConnectionTerminatedCallback(HeliosConnectionException reason, IConnection closedChannel) { //log }
protected abstract void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel);
protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel) { ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Unknown)); }
private void ConnectionTerminatedCallback(HeliosConnectionException reason, IConnection closedchannel) { Terminated?.Invoke(reason, closedchannel); }