Session

Session

IMu.Session

IMu.Session

Since: 1.0

Description

Manages a connection to an IMu server. The server’s host name and port can be specified by setting properties on the object or by setting class-based default properties.

Examples

  1. Connect to the default server.

    using IMu;
    Session session = new Session();
    session.Connect();
  2. Set the default host and port and then connect.

    using IMu;
    Session.DefaultHost = "server.com";
    Session.DefaultPort = 40136;
    
    Session session = new Session();
    session.Connect();
    

Class Properties

Class Property

Details

DefaultHost

string DefaultHost

The name of the host used to create a connection if no object-specific host has been supplied.

DefaultPort

int DefaultPort

The number of the port used to create a connection if no object-specific host has been supplied.

Constructors

Constructor

Details

Session(host, port)

Session(string host, int port)

Creates a Session object with the specified host and port.

Parameters:

host (string)

The default server host.

port (int)

The default server port.

Session(host)

Session(string host)

Creates a Session object with the specified host.

The port to connect on will be taken from the DefaultPort class property.

Parameters:

host (string)

The default server host.

Session(port)

Session(int port)

Creates a Session object with the specified port.

The host to connect to will be taken from the DefaultHost class property.

Parameters:

port (int)

The default server port.

Session()

Session()

Creates a Session object.

The host to connect to will be taken from the DefaultHost class property.

The port to connect on will be taken from the DefaultPort class property.

Properties

Property

Details

Close

bool Close

A flag controlling whether the connection to the server should be closed after the next request. This flag is passed to the server as part of the next request to allow it to clean up.

Context

string Context

The unique identifier assigned by the server to the current session.

Host

string Host

The name of the host used to create the connection. Setting this property after the connection has been established has no effect.

Port

int Port

The number of the port used to create the connection. Setting this property after the connection has been established has no effect.

Suspend

bool Suspend

A flag controlling whether the server process handling this session should begin listening on a distinct, process-specific port to ensure a new session connects to the same server process.

This is part of IMu's mechanism for maintaining state. If this flag is set to true, then after the next request is made to the server, the Session's port property will be altered to the process-specific port number.

Methods

Method

Details

Connect()

void Connect()

Opens a connection to an IMu server.

Returns:

void

 

Throws:

IMuException

The connection could not be opened.

Disconnect()

void Disconnect()

Closes the connection to the IMu server.

Returns:

void

 

Login(login, password, spawn)

Map Login(string login, string password, bool spawn)

Logs in as the given user with the given password.

The password parameter may be null. This will cause the server to use server-side authentication (such as .rhosts authentication) to authenticate the user.

Parameters:

login (string)

The name of the user to login as.

password (string)

The user's password for authentication.

spawn (bool)

A flag indicating whether the process should create a new child process specifically for handling the newly logged in user's requests. This value defaults to true.

Returns:

Map  

Throws:

IMuException

The login request failed.

Exception

A low-level socket communication error occurred.

Login(login, password)

Map Login(string login, string password)

Logs in as the given user with the given password.

The password parameter may be null. This will cause the server to use server-side authentication (such as .rhosts authentication) to authenticate the user.

spawn defaults to true causing the server to create a new child process specifically for handling the newly logged in user's requests.

Parameters:

login (string)

The name of the user to login as.

password (string)

The user's password for authentication.

Returns:

Map  

Throws:

IMuException

The login request failed.

Exception

A low-level socket communication error occurred.

Login(login)

Map Login(string login)

Logs in as the given user. Uses server-side authentication (such as .rhosts authentication) to authenticate the user.

The server will spawn a new child process specifically for handling the newly logged in user's requests.

Parameters:

login (string)

The name of the user to login as.

Returns:

Map  

Throws:

IMuException

The login request failed.

Exception

A low-level socket communication error occurred.

Logout()

Map Logout()

Logs the user out of the server.

Returns:

Map  

Request(request)

Map Request(Map request)

Submits a low-level request to the IMu server.

Parameters:

request (Map)

A Map containing the request parameters.

Returns:

Map

A Map object containing the server's response.

Throws:

IMuException

If a server-side error occurred.