![]() |
![]() |
![]() |
libinfinity-0.5 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
InfAdoptedSessionInfAdoptedSession — Session handling concurrency control via the adOPTed algorithm. |
#include <libinfinity/adopted/inf-adopted-session.h> enum InfAdoptedSessionError; InfAdoptedSession; InfAdoptedSessionClass; InfIo * inf_adopted_session_get_io (InfAdoptedSession *session
); InfAdoptedAlgorithm * inf_adopted_session_get_algorithm (InfAdoptedSession *session
); void inf_adopted_session_broadcast_request (InfAdoptedSession *session
,InfAdoptedRequest *request
); void inf_adopted_session_undo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
); void inf_adopted_session_redo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
); gboolean inf_adopted_session_read_request_info (InfAdoptedSession *session
,xmlNodePtr xml
,InfAdoptedStateVector *diff_vec
,InfAdoptedUser **user
,InfAdoptedStateVector **time
,xmlNodePtr *operation
,GError **error
); void inf_adopted_session_write_request_info (InfAdoptedSession *session
,InfAdoptedRequest *request
,InfAdoptedStateVector *diff_vec
,xmlNodePtr xml
,xmlNodePtr operation
);
"algorithm" InfAdoptedAlgorithm* : Read "io" InfIo* : Read / Write / Construct Only "max-total-log-size" guint : Read / Write / Construct Only
InfAdoptedSession handles concurrency control with an InfAdoptedAlgorithm on top of a InfSession. It takes care of sending all necessary information to joining users, receives requests from the network (passing them to InfAdoptedAlgorithm) and transfers local requests to the other users. It also makes sure to periodically send the state the local host is in to other uses even if the local users are idle (which is required for others to cleanup their request logs and request caches).
typedef enum _InfAdoptedSessionError { INF_ADOPTED_SESSION_ERROR_NO_SUCH_USER, INF_ADOPTED_SESSION_ERROR_MISSING_OPERATION, INF_ADOPTED_SESSION_ERROR_INVALID_REQUEST, INF_ADOPTED_SESSION_ERROR_MISSING_STATE_VECTOR, INF_ADOPTED_SESSION_ERROR_FAILED } InfAdoptedSessionError;
Error codes for InfAdoptedSession. These only occur when invalid requests are received from the network.
The "user" field in a request message does not contain a valid user ID. | |
A request message does not contain an operation. | |
A request in a synchronized request log is invalid. Invalid means that it is not the request that was issued after the previous request in the log, or that it is an Undo or Redo request without a request to Undo or Redo, respectively. | |
A synchronized user does not contain that the state that user currently is in. | |
No further specified error code. |
typedef struct _InfAdoptedSession InfAdoptedSession;
InfAdoptedSession is an opaque data type. You should only access it via the public API functions.
typedef struct { InfAdoptedRequest*(*xml_to_request)(InfAdoptedSession* session, xmlNodePtr xml, InfAdoptedStateVector* diff_vec, gboolean for_sync, GError** error); void(*request_to_xml)(InfAdoptedSession* session, xmlNodePtr xml, InfAdoptedRequest* request, InfAdoptedStateVector* diff_vec, gboolean for_sync); } InfAdoptedSessionClass;
Virtual functions for InfAdoptedSession.
Virtual function to deserialize an InfAdoptedRequest
from XML. The implementation of this function can use
inf_adopted_session_read_request_info() to read the common info.
|
|
Virtual function to serialize an InfAdoptedRequest
to XML. This function should add properties and children to the given XML
node. At might use inf_adopted_session_write_request_info() to write the
common info.
|
InfIo * inf_adopted_session_get_io (InfAdoptedSession *session
);
Returns the InfIo object of session
.
|
A InfAdoptedSession. |
Returns : |
A InfIo. |
InfAdoptedAlgorithm * inf_adopted_session_get_algorithm (InfAdoptedSession *session
);
Returns the InfAdoptedAlgorithm object of session
. Returns NULL
if
session
has status INF_SESSION_PRESYNC
or INF_SESSION_SYNCHRONIZING
because there the algorithm object is not yet created before successful
synchronization.
|
A InfAdoptedSession. |
Returns : |
A InfAdoptedAlgorithm, or NULL .
|
void inf_adopted_session_broadcast_request (InfAdoptedSession *session
,InfAdoptedRequest *request
);
Sends a request to all subscribed connections. The request should originate
from a call to inf_adopted_algorithm_generate_request_noexec()
,
inf_adopted_algorithm_generate_request()
,
inf_adopted_algorithm_generate_undo()
or
inf_adopted_algorithm_generate_redo()
with session
's InfAdoptedAlgorithm.
|
A InfAdoptedSession. |
|
A InfAdoptedRequest obtained from session 's algorithm.
|
void inf_adopted_session_undo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
);
This is a shortcut for creating n
undo requests and broadcasting them.
If n
> 1 then this is also more efficient.
|
A InfAdoptedSession. |
|
A local InfAdoptedUser. |
|
The number of undo requests to issue. |
void inf_adopted_session_redo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
);
This is a shortcut for creating n
redo requests and broadcasting them.
If n
> 1 then this is also more efficient.
|
A InfAdoptedSession. |
|
A local InfAdoptedUser. |
|
The number of redo requests to issue. |
gboolean inf_adopted_session_read_request_info (InfAdoptedSession *session
,xmlNodePtr xml
,InfAdoptedStateVector *diff_vec
,InfAdoptedUser **user
,InfAdoptedStateVector **time
,xmlNodePtr *operation
,GError **error
);
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.
|
A InfAdoptedSession. |
|
The XML to read the data from. |
|
The reference vector of the time vector of the request, or
NULL .
|
|
Location to store the user of the request, or NULL .
|
|
Location to store the state the request was made, or NULL .
|
|
Location to store the operation of the request, or NULL .
|
|
Location to place an error, if any. |
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.
|
void inf_adopted_session_write_request_info (InfAdoptedSession *session
,InfAdoptedRequest *request
,InfAdoptedStateVector *diff_vec
,xmlNodePtr xml
,xmlNodePtr operation
);
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 inf_adopted_state_vector_to_string_diff()
. Deserializing this data
again (via inf_adopted_session_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.
|
A InfAdoptedSession. |
|
The InfAdoptedRequest whose info to write. |
|
A reference state vector, or NULL .
|
|
The XML node to write the data into. |
|
An XML node representing the operation of the request, or
NULL .
|
"algorithm"
property"algorithm" InfAdoptedAlgorithm* : Read
The adOPTed algorithm used for translating incoming requests.