示例#1
0
 /// <summary>
 /// Fires whenever a Helios <see cref="IConnection"/> received data from the network.
 /// </summary>
 /// <param name="data">The message playload.</param>
 /// <param name="responseChannel">
 /// The channel responsible for sending the message.
 /// Can be used to send replies back.
 /// </param>
 protected override void OnMessage(NetworkData data, IConnection responseChannel)
 {
     if (data.Length > 0)
     {
         ChannelLocalActor.Notify(responseChannel, new InboundPayload(FromData(data)));
     }
 }
示例#2
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);
        }
示例#3
0
 /// <summary>
 /// Fires whenever a Helios <see cref="IConnection"/> experienced a non-fatal error.
 ///
 /// <remarks>The connection should still be open even after this event fires.</remarks>
 /// </summary>
 /// <param name="ex">The execption that triggered this event.</param>
 /// <param name="erroredChannel">The handle to the Helios channel that errored.</param>
 protected override void OnException(Exception ex, IConnection erroredChannel)
 {
     // Want to notify only for encoding exceptions
     if (!(ex is HeliosConnectionException))
     {
         ChannelLocalActor.Notify(erroredChannel, new UnderlyingTransportError(ex, "Non-fatal network error occurred inside underlying transport"));
     }
 }
示例#4
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);
        }
示例#5
0
 protected override void OnException(Exception ex, IConnection erroredChannel)
 {
     ChannelLocalActor.Notify(erroredChannel, new UnderlyingTransportError(ex, "Non-fatal network error occurred inside underlying transport"));
 }
 protected override void OnException(Exception ex, IConnection erroredChannel)
 {
     ChannelLocalActor.Notify(erroredChannel, new Disassociated(DisassociateInfo.Unknown));
     erroredChannel.Close();
 }
 protected override void OnDisconnect(HeliosConnectionException cause, IConnection closedChannel)
 {
     ChannelLocalActor.Notify(closedChannel, new Disassociated(DisassociateInfo.Unknown));
 }