Class SessionState

The state of a ISession.

Inheritance
System.Object
SessionState
Namespace: PushTechnology.ClientInterface.Client.Session
Assembly: Diffusion.Client.dll
Syntax
public sealed class SessionState : object
Remarks

Added in 5.0.

Examples

An instance of this class can be obtained by the StateChanged event.

var factory = Diffusion.Sessions.SessionStateChangedHandler(
    (sender, args) => {
        var previous = args.OldState;
        var current = args.NewState;
    } );

Fields

CLOSE_FAILED

The session has lost its connection to a server and could not be recovered.

Declaration
public static readonly SessionState CLOSE_FAILED
Field Value
Type Description
SessionState

Connected: false, Recovering: false, Closed: true

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.CLOSE_FAILED;

Console.WriteLine( state.Connected ); // Prints "false"
Console.WriteLine( state.Recovering ); // Prints "false"
Console.WriteLine( state.Closed ); // Prints "true"

CLOSED_BY_CLIENT

The session has been closed by the client.

Declaration
public static readonly SessionState CLOSED_BY_CLIENT
Field Value
Type Description
SessionState

Connected: false, Recovering: false, Closed: true

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.CLOSED_BY_CLIENT;

Console.WriteLine( state.Connected ); // Prints "false"
Console.WriteLine( state.Recovering ); // Prints "false"
Console.WriteLine( state.Closed ); // Prints "true"

CLOSED_BY_SERVER

The session has been closed (or rejected) by the server.

Declaration
public static readonly SessionState CLOSED_BY_SERVER
Field Value
Type Description
SessionState

Connected: false, Recovering: false, Closed: true

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.CLOSED_BY_SERVER;

Console.WriteLine( state.Connected ); // Prints "false"
Console.WriteLine( state.Recovering ); // Prints "false"
Console.WriteLine( state.Closed ); // Prints "true"

CONNECTED_ACTIVE

An active connection with the server has been established.

Declaration
public static readonly SessionState CONNECTED_ACTIVE
Field Value
Type Description
SessionState

Connected: true, Recovering: false, Closed: false

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.CONNECTED_ACTIVE;

Console.WriteLine( state.Connected ); // Prints "true"
Console.WriteLine( state.Recovering ); // Prints "false"
Console.WriteLine( state.Closed ); // Prints "false"

CONNECTING

The session is establishing its initial connection.

Declaration
public static readonly SessionState CONNECTING
Field Value
Type Description
SessionState

Connected: false, Recovering: false, Closed: false

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.CONNECTING;

Console.WriteLine( state.Connected ); // Prints "false"
Console.WriteLine( state.Recovering ); // Prints "false"
Console.WriteLine( state.Closed ); // Prints "false"

RECOVERING_RECONNECT

Connection with a server has been lost and the session is attempting reconnection.

Declaration
public static readonly SessionState RECOVERING_RECONNECT
Field Value
Type Description
SessionState

Connected: false, Recovering: true, Closed: false

Remarks

Added in 5.0.

Examples

Print various properties of an instance of this field to the terminal.

var state = SessionState.RECOVERING_RECONNECT;

Console.WriteLine( state.Connected ); // Prints "false"
Console.WriteLine( state.Recovering ); // Prints "true"
Console.WriteLine( state.Closed ); // Prints "false"

Properties

Closed

Gets whether the session is closed.

Declaration
public bool Closed { get; }
Property Value
Type Description
System.Boolean

true if the session is closed. Otherwise false.

Remarks

Added in 5.0.

Examples

Check whether a given session state is closed or not.

// state is a previously obtained SessionState instance
if ( state.Closed ) {
    Console.WriteLine( "State is closed." );
} else {
    Console.WriteLine( "State is not closed." );
}

Connected

Gets whether the session is connected.

Declaration
public bool Connected { get; }
Property Value
Type Description
System.Boolean

true if the session is connected. Otherwise false.

Remarks

Added in 5.0.

Examples

Check whether a given session state is connected or not.

// state is a previously obtained SessionState instance
if ( state.Connected ) {
    Console.WriteLine( "State is connected." );
} else {
    Console.WriteLine( "State is not connected." );
}

Recovering

Gets whether the session is recovering.

Declaration
public bool Recovering { get; }
Property Value
Type Description
System.Boolean

true if the session is recovering. Otherwise false.

Remarks

Added in 5.0.

Examples

Check whether a given session state is recovering or not.

// state is a previously obtained SessionState instance
if ( state.Recovering ) {
    Console.WriteLine( "State is recovering." );
} else {
    Console.WriteLine( "State is not recovering." );
}

Methods

ToString()

Returns a string that represents the current session state.

Declaration
public override string ToString()
Returns
Type Description
System.String

The string that represents the current session state.

Back to top