Changes between Version 9 and Version 10 of Infinote/Protocol

Show
Ignore:
Timestamp:
10/02/08 14:46:04 (5 years ago)
Author:
armin (IP: 87.178.239.221)
Comment:

Updated InfText? messages

Legend:

Unmodified
Added
Removed
Modified
  • Infinote/Protocol

    v9 v10  
    66 
    77TODO: List error domains and codes 
     8 
     9TODO: Max-Total-Log-Size 
    810 
    911The basic Infinote protocol uses XML and can be used over any transport that can deliver XML messages between hosts, such as XMPP. 
     
    451453== InfText messages == 
    452454 
     455This section describes additional messages that are used for text sessions. 
     456 
    453457=== State vectors === 
    454458 
     
    461465Some attributes of the following messages describe such a state vector. The state vector has the form "user_id:processed_requests;user_id:processed_requests;[...]" where user_id is the ID of a user and processed_requests describe the number of requests that this user is guaranteed to have already processed. 
    462466 
     467==== State Vector Diffs ==== 
     468 
     469State Vectors can also be sent as a "Diff", which means relative to a state vector sent previously. 
     470 
     471For example, if such a diff contains the value "2:3;1:1", this means that the value 3 needs to be added to the processed requests of user 2 of the reference state vector, and 1 to the requests of user 1. 
     472 
     473=== Operations === 
     474 
     475Some fields of the InfText messages use operations to describe a change that has been made to the document. This section defines what operations are allowed. 
     476 
     477There are two types of operations. Such operations that modify the document and such that do not. For example, inserting a character into the document does modify it, but moving the cursor of a user does not. If the operation of a request does not modify the document, the request is not recorded into the request log (and cannot be undone). 
     478 
     479{{{ 
     480<insert pos="pos">text</insert> 
     481<insert-caret pos="pos">text</insert-caret> 
     482}}} 
     483 
     484 * pos, Integer: The character offset at which to insert text. 
     485 * text, String: The text to insert. 
     486 
     487An operation that inserts new text into the document. The <insert-caret> version additionally places the cursor of the user that made the request behind the inserted text. 
     488 
     489{{{ 
     490<delete pos="pos" len="len" /> 
     491<delete-caret pos="pos" len="len" /> 
     492}}} 
     493 
     494 * pos, Integer: The character offset at which to start deleting characters 
     495 * len, Integer: The number of characters to delete. 
     496 
     497Deletes text from the buffer. This operation is only used in <request /> messages. Again, <delete-caret /> additionally places the cursor of the user that made the request to the place where characters have been deleted. 
     498 
     499{{{ 
     500<delete pos="pos"><segment author="user_id">text</segment>[...]</delete> 
     501}}} 
     502 
     503 * pos, Integer: The character offset at which to start deleting characters. 
     504 * segments: The text that was deleted, including author information, i.e. which user wrote what text. 
     505 
     506Deletes text from the buffer and specifies what text is deleted. This operation is only used in <sync-request /> messages. The synchronization client cannot deduce what text was actually deleted, but must be able to compute the reverse operation in case someone undoes the request. In a normal <request /> message, other users can deduce what text was deleted by having a look at the document and which transformations were required to transform the request to the current state before the operation is actually executed. 
     507 
     508{{{ 
     509<no-op /> 
     510}}} 
     511 
     512Does nothing, and does especially not modify the document (see above). This is used when a user was inactive for some time to report its current state vector to the other users. 
     513 
     514{{{ 
     515<move caret="pos" selection="len" /> 
     516}}} 
     517 
     518 * pos, Integer: The character offset to place the cursor to. 
     519 * len, Integer: The length of the selection area, in characters. Negative values mean selection towards the beginning of the document. 
     520 
     521Changes the position of the user's cursor position and selection area. This operation does not modify the document. 
     522 
     523{{{ 
     524<undo /> 
     525<undo-caret /> 
     526}}} 
     527 
     528Undoes the previous request of the user. The <undo-caret /> version also places the user's cursor to the position where the operation was performed. 
     529 
     530{{{ 
     531<redo /> 
     532<redo-caret /> 
     533}}} 
     534 
     535Redoes the previous request of the user. The <redo-caret /> version also places the user's cursor to the position where the operation was performed. 
     536 
    463537=== User attributes === 
    464538 
    465 The following attributes are used in the <sync-user> and <join-user> requests for text sessions: 
     539The following attributes are used in the <sync-user /> and <join-user /> requests for text sessions: 
    466540 
    467541 * time, StateVector: The current state vector of the user 
    468  * caret: The position of the user's cursor, in characters, from the document beginning 
    469  * selection: The number of characters selected, starting at the character caret. Negative means selection towards the beginning of the document. 
     542 * caret, Integer: The position of the user's cursor, in characters, from the document beginning 
     543 * selection, Integer: The number of characters selected, starting at the character caret. Negative means selection towards the beginning of the document. 
     544 * hue, Float: A floating point number between 0.0 (red) and 1.0 (red), specifying the user's color. 
    470545 
    471546TODO: Viewport 
     
    483558 * user, Integer: The ID of the user that made the request. 
    484559 * time, State Vector: The state at which the request was made. 
    485  * operation: The operation performed by the request, see below. 
    486  
    487 Tells that at the given time a user made a request. This should be added to the request log and might be necessary to transform incoming operations or to compute Undo operations. 
     560 * operation, Operation: The operation performed by the request, see below. 
     561 
     562Tells that at the given time a user made a request. The request is already included in the document content sent via <sync-segment /> messages. However, the request should be added to the request log and might be necessary to transform incoming operations or to compute Undo operations. 
    488563 
    489564{{{ 
     
    494569 * Text: The text that user wrote. 
    495570 
    496 Synchronizes a part of the initial document that was written by a single user. The <sync-segment> messages should be sent in-order so the document can be reconstructed. 
    497  
    498 === Independant === 
    499  
    500 These messages are sent no matter whether being client or server. 
     571Synchronizes a continous part of the initial document that was written by a single user. The <sync-segment> messages must be sent in-order so the document can be reconstructed. 
     572 
     573=== Group messages === 
     574 
     575These messages can be sent from each group member to other group members. 
    501576 
    502577{{{ 
     
    507582 
    508583 * user, Integer: The ID of the user that made the request. 
    509  * time, State Vector diff: Describes the document state at which the request was made. 
    510  * operation: The operation performed by the request, see below. 
    511  
    512 Whenever a user issues a request the <request> message is sent. The user must have joined via the connection the request message comes from. <request> is sent to the whole subscription group. The time sent with this message is not absolute, but relative to the time from the last request of this user. For, example, if time contains the value "2:3;1:1", this means that since the last request of that user, it processed 3 requests from user 2 and one request from user 1. Note that the  value for the user itself is therefore always zero, because there cannot be any requests inbetween them. This requires the requests from some user to arrive in-order, but it state vector components from inactive (or users that have left the session) need not to be transmitted all the time. 
    513  
    514 === Operations === 
    515  
    516 There are two types of operations. Such operations that modify the document and such that do not. For example, inserting a character into the document does modify it, but moving the cursor of a user does not. If the operation of a request does not modify the document, the request is not recorded in the request log. 
    517  
    518 The following operations are defined: 
    519  
    520 {{{ 
    521 <insert pos="pos">text</insert> 
    522 <insert-caret pos="pos">text</insert-caret> 
    523 }}} 
    524  
    525  * pos, Integer: The character offset at which to insert text. 
    526  * text, String: The text to insert. 
    527  
    528 An operation that inserts new text into the document. The <insert-caret> version additionally places the cursor of the user that made the request behind the inserted text. 
    529  
    530 {{{ 
    531 <delete pos="pos" len="len" /> 
    532 <delete-caret pos="pos" len="len" /> 
    533 }}} 
    534  
    535  * pos, Integer: The character offset at which to start deleting characters 
    536  * len, Integer: The number of characters to delete. 
    537  
    538 Deletes text from the buffer. This operation is only used in <request> messages. Again, <delete-caret> additionally places the cursor of the user that made the request to the place where characters have been deleted. 
    539  
    540 {{{ 
    541 <delete pos="pos"><segment author="user_id">text</segment>[...]</delete> 
    542 }}} 
    543  
    544  * pos, Integer: The character offset at which to start deleting characters. 
    545  * segments: The text that was deleted, including author information, i.e. which user wrote what text. 
    546  
    547 Deletes text from the buffer and specifies what text is deleted. This operation is only used in <sync-request> messages. The synchronization client cannot deduce what text was actually deleted, but must be able to compute the reverse operation in case someone undoes the request. In a normal <request> message, other users can deduce what text was deleted by having a look at the document and which transformations were required to transform the request to the current state before the operation is actually executed. 
    548  
    549 {{{ 
    550 <no-op /> 
    551 }}} 
    552  
    553 Does nothing, and does especially not modify the document (see above). This is used when a user was inactive for some time to report its current state vector to the other users. 
    554  
    555 {{{ 
    556 <move caret="pos" selection="len" /> 
    557 }}} 
    558  
    559  * pos, Integer: The character offset to place the cursor to. 
    560  * len, Integer: The length of the selection area, in characters. Negative values mean selection towards the beginning of the document. 
    561  
    562 Changes the position of the user's cursor position and selection area. This operation does not modify the document. 
    563  
    564 {{{ 
    565 <undo /> 
    566 <undo-caret /> 
    567 }}} 
    568  
    569 Undoes the last request of the user. The <undo-caret> version also places the user's cursor to the position where the operation was performed. 
    570  
    571 {{{ 
    572 <redo /> 
    573 <redo-caret /> 
    574 }}} 
    575  
    576 Redoes the last request of the user. The <redo-caret> version also places the user's cursor to the position where the operation was performed. 
     584 * time, State Vector Diff: Describes the document state at which the request was made. 
     585 * operation, Operation: The operation performed by the request, see below. 
     586 
     587Whenever a user issues a request the <request> message is sent. The user must have joined via the connection the request message comes from. <request> is sent to the whole subscription group. The time is a State Vector Diff, with the previous time sent by that user being the reference state vector. Therefore, it requires the requests from some user to arrive in-order, but state vector components from inactive users (or ones that have left the session) need not to be transmitted all the time. Note that the value for the user itself is therefore always zero, because there cannot be any requests inbetween them. 
    577588 
    578589== Concurrency Control == 
     
    612623      v := associated_request(r).v; 
    613624}}} 
    614    r.v() is the state vector at which request r was made. The function associated_request returns request the given request r undoes (which is a DO or REDO request if r is a UNDO request, or an UNDO request if r is a REDO request). In the following diagram DO operations at (0,0), (0,1) and an UNDO operation at (1,1) have been issued. Note that the point (2,0) is reachable by folding from (0,0). The translation path of the blue request from (0,0) to (2,1) shows how it may be used. Although there exists another path in this example where (2,0) does not need to be reachable, the tests described in [svn://svn.0x539.de/infinote/trunk/test/std/test-21.xml test/std/test-21.xml] and [svn://svn.0x539.de/infinote/trunk/test/std/test-46.xml test/std/test-46.xml] fail with the original definition of the Reachable function. 
     625   r.v() is the state vector at which request r was made. The function associated_request returns request the given request r undoes (which is a DO or REDO request if r is a UNDO request, or an UNDO request if r is a REDO request). In the following diagram DO operations at (0,0), (0,1) and an UNDO operation at (1,1) have been issued. Note that the point (2,0) is reachable by folding from (0,0). The translation path of the blue request from (0,0) to (2,1) shows how it may be used. Although there exists another path in this example where (2,0) does not need to be reachable, the tests described in [http://git.0x539.de/?p=infinote.git;a=blob;f=test/session/test-21.xml;hb=master test/std/test-21.xml] and [http://git.0x539.de/?p=infinote.git;a=blob;f=test/session/test-46.xml;hb=master test/std/test-46.xml] fail with the original definition of the Reachable function. 
    615626 
    616627   [[Image(http://infinote.0x539.de/illustrations/extended-reachable.png)]]