Infinity.AdoptedSession

g GObject.GInterface GObject.GInterface Infinity.CommunicationObject Infinity.CommunicationObject GObject.GInterface->Infinity.CommunicationObject GObject.Object GObject.Object Infinity.Session Infinity.Session GObject.Object->Infinity.Session Infinity.AdoptedSession Infinity.AdoptedSession Infinity.CommunicationObject->Infinity.Session Infinity.Session->Infinity.AdoptedSession

Subclasses:

None

Methods

Inherited:

Infinity.Session (19), GObject.Object (37), Infinity.CommunicationObject (3)

Structs:

GObject.ObjectClass (5)

broadcast_request (request)

get_algorithm ()

get_io ()

read_request_info (xml, diff_vec)

redo (user, n)

undo (user, n)

write_request_info (request, diff_vec, xml, operation)

Virtual Methods

Inherited:

Infinity.Session (11), GObject.Object (7), Infinity.CommunicationObject (3)

do_check_request (request, user)

do_request_to_xml (xml, request, diff_vec, for_sync)

Properties

Inherited:

Infinity.Session (7)

Name

Type

Flags

Short Description

algorithm

Infinity.AdoptedAlgorithm

r

The adOPTed algorithm used for translating incoming requests

io

Infinity.Io

r/w/co

The IO object used for timeouts

max-total-log-size

int

r/w/co

The maximum number of requests to keep in all user’s logs

Signals

Inherited:

Infinity.Session (6), GObject.Object (1)

Name

Short Description

check-request

This signal is emitted whenever the session received a request from a non-local user.

Fields

Inherited:

Infinity.Session (6), GObject.Object (1)

Name

Type

Access

Description

parent

Infinity.Session

r

Class Details

class Infinity.AdoptedSession(**kwargs)
Bases:

Infinity.Session

Abstract:

No

Structure:

Infinity.AdoptedSessionClass

Infinity.AdoptedSession is an opaque data type. You should only access it via the public API functions.

broadcast_request(request)
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest obtained from self's algorithm.

Sends a request to all subscribed connections. The request should originate from a call to Infinity.AdoptedAlgorithm.generate_request(), with self's Infinity.AdoptedAlgorithm.

get_algorithm()
Returns:

A Infinity.AdoptedAlgorithm, or None.

Return type:

Infinity.AdoptedAlgorithm

Returns the Infinity.AdoptedAlgorithm object of self. Returns None if self has status Infinity.SessionStatus.PRESYNC or Infinity.SessionStatus.SYNCHRONIZING because there the algorithm object is not yet created before successful synchronization.

get_io()
Returns:

A Infinity.Io.

Return type:

Infinity.Io

Returns the Infinity.Io object of self.

read_request_info(xml, diff_vec)
Parameters:
Raises:

GLib.Error

Returns:

True if the data could be read successfully, False if the XML request does not contain valid request data, in which case error is set.

user:

Location to store the user of the request, or None.

time:

Location to store the state the request was made, or None.

operation:

Location to store the operation of the request, or None.

Return type:

(bool, user: Infinity.AdoptedUser, time: Infinity.AdoptedStateVector, operation: libxml2.NodePtr)

This function reads common information such as the state vector the request was made and the user that made the request from XML. It is most likely to be used by implementations of the xml_to_request virtual function.

redo(user, n)
Parameters:

This is a shortcut for creating n redo requests and broadcasting them. If n > 1 then this is also more efficient.

undo(user, n)
Parameters:

This is a shortcut for creating n undo requests and broadcasting them. If n > 1 then this is also more efficient.

write_request_info(request, diff_vec, xml, operation)
Parameters:

This function writes common data from request, such as the user that issued the request and the state in which the request was made into xml. If diff_vec is given, then the state is written as a diff to this vector, see Infinity.AdoptedStateVector.to_string_diff(). Deserializing this data again (via Infinity.AdoptedSession.read_request_info()) requires the same diff_vec then.

This function is most likely to be used by implementations of the request_to_xml virtual function.

do_check_request(request, user) virtual
Parameters:
Return type:

bool

do_request_to_xml(xml, request, diff_vec, for_sync) virtual
Parameters:

Signal Details

Infinity.AdoptedSession.signals.check_request(adopted_session, request, user)
Signal Name:

check-request

Flags:

RUN_LAST

Parameters:
Return type:

bool

This signal is emitted whenever the session received a request from a non-local user. It is used to decide whether the request should be processed or not. Note that generally not processing a request results is loss of synchronization, since other hosts might process the request. Only if the same condition can be applied on all sites a request should be rejected. Another possibility is to reject a request at a central host before it gets distributed to all other clients. If there is one signal handler returning True the request is rejected, i.e. only if all signal handlers return False it is accepted.

Property Details

Infinity.AdoptedSession.props.algorithm
Name:

algorithm

Type:

Infinity.AdoptedAlgorithm

Default Value:

None

Flags:

READABLE

The adOPTed algorithm used for translating incoming requests

Infinity.AdoptedSession.props.io
Name:

io

Type:

Infinity.Io

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The IO object used for timeouts

Infinity.AdoptedSession.props.max_total_log_size
Name:

max-total-log-size

Type:

int

Default Value:

2048

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The maximum number of requests to keep in all user’s logs