Table of Contents

Class SessionState

Namespace
PushTechnology.ClientInterface.Client.Session
Assembly
Diffusion.Client.dll

The state of a ISession.

public sealed class SessionState
Inheritance
SessionState
Inherited Members

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;
    } );

Remarks

Added in 5.0.

Fields

CLOSED_BY_CLIENT

The session has been closed by the client.

public static readonly SessionState CLOSED_BY_CLIENT

Field Value

SessionState

Connected: false, Recovering: false, Closed: true

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"

Remarks

Added in 5.0.

CLOSED_BY_SERVER

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

public static readonly SessionState CLOSED_BY_SERVER

Field Value

SessionState

Connected: false, Recovering: false, Closed: true

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"

Remarks

Added in 5.0.

CLOSE_FAILED

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

public static readonly SessionState CLOSE_FAILED

Field Value

SessionState

Connected: false, Recovering: false, Closed: true

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"

Remarks

Added in 5.0.

CONNECTED_ACTIVE

An active connection with the server has been established.

public static readonly SessionState CONNECTED_ACTIVE

Field Value

SessionState

Connected: true, Recovering: false, Closed: false

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"

Remarks

Added in 5.0.

CONNECTING

The session is establishing its initial connection.

public static readonly SessionState CONNECTING

Field Value

SessionState

Connected: false, Recovering: false, Closed: false

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"

Remarks

Added in 5.0.

RECOVERING_RECONNECT

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

public static readonly SessionState RECOVERING_RECONNECT

Field Value

SessionState

Connected: false, Recovering: true, Closed: false

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"

Remarks

Added in 5.0.

Properties

Closed

Gets whether the session is closed.

public bool Closed { get; }

Property Value

bool

true if the session is closed. Otherwise false.

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." );
}

Remarks

Added in 5.0.

Connected

Gets whether the session is connected.

public bool Connected { get; }

Property Value

bool

true if the session is connected. Otherwise false.

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." );
}

Remarks

Added in 5.0.

Recovering

Gets whether the session is recovering.

public bool Recovering { get; }

Property Value

bool

true if the session is recovering. Otherwise false.

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." );
}

Remarks

Added in 5.0.

Methods

ToString()

Returns a string that represents the current session state.

public override string ToString()

Returns

string

The string that represents the current session state.