Session for sharing an mxGraphModel with other parties via a backend that acts as a multicaster for all changes.
The diagram sharing is a mechanism where each atomic change of the model is encoded into XML using mxCodec and then transmitted to the server by the mxSession object. On the server, the XML data is dispatched to each listener on the same diagram (except the sender), and the XML is decoded back into atomic changes on the client side, which are then executed on the model and stored in the command history.
The mxSession.significantRemoteChanges specifies how these changes are treated with respect to undo: The default value (true) will undo the last change regardless of whether it was a remote or a local change. If the switch is false, then an undo will go back until the last local change, silently undoing all remote changes up to that point. Note that these changes will be added as new remote changes to the history of the other clients.
mxSession | Session for sharing an mxGraphModel with other parties via a backend that acts as a multicaster for all changes. |
Events | |
mxEvent. | Fires after the session has been started, that is, after the response to the initial request was received and the session goes into polling mode. |
mxEvent. | Fires after suspend was called an the session was not already in suspended state. |
mxEvent. | Fires after the session was resumed in resume. |
mxEvent. | Fires after the session was stopped in stop. |
mxEvent. | Fires after a notification was sent in notify. |
mxEvent.GET | Fires after a response was received in get. |
mxEvent. | Fires after an array of edits has been executed on the model. |
mxEvent. | Fires after an XML node was received in receive. |
Functions | |
mxSession | Constructs a new session using the given mxGraphModel and URLs to communicate with the backend. |
Variables | |
model | Reference to the enclosing mxGraphModel. |
urlInit | URL to initialize the session. |
urlPoll | URL for polling the backend. |
urlNotify | URL to send changes to the backend. |
codec | Reference to the mxCodec used to encoding and decoding changes. |
linefeed | Used for encoding linefeeds. |
escapePostData | Specifies if the data in the post request sent in notify should be converted using encodeURIComponent. |
significantRemoteChanges | Whether remote changes should be significant in the local command history. |
sent | Total number of sent bytes. |
received | Total number of received bytes. |
debug | Specifies if the session should run in debug mode. |
connected | |
send | |
polling | |
Functions | |
start | |
suspend | Suspends the polling. |
resume | Resumes the session if it has been suspended. |
stop | Stops the session and fires a disconnect event. |
poll | Sends an asynchronous GET request to urlPoll. |
notify | Sends out the specified XML to urlNotify and fires a notify event. |
get | Sends an asynchronous get request to the given URL, fires a get event and invokes the given onLoad function when a response is received. |
isValidResponse | Returns true if the response data in the given mxXmlRequest is valid. |
encodeChanges | Returns the XML representation for the given array of changes. |
receive | Processes the given node by applying the changes to the model. |
processState | Processes the given state node which contains the current state of the remote model. |
processDelta | Processes the given delta node which contains a sequence of edits which in turn map to one transaction on the remote model each. |
processEdit | Processes the given edit by executing its changes and firing the required events via the model. |
createUndoableEdit | Creates a new mxUndoableEdit that implements the notify function to fire a <change> and notify event via the model. |
decodeChanges | Decodes and executes the changes represented by the children in the given node. |
cellRemoved | Adds removed cells to the codec object lookup for references to the removed cells after this point in time. |
Fires after suspend was called an the session was not already in suspended state. This event has no properties.
Fires after the session was resumed in resume. This event has no properties.
Fires after the session was stopped in stop. The <code>reason</code> property contains the optional exception that was passed to the stop method.
Fires after a notification was sent in notify. The <code>url</code> property contains the URL and the <code>xml</code> property contains the XML data of the request.
Fires after a response was received in get. The <code>url</code> property contains the URL and the <code>request</code> is the mxXmlRequest that contains the response.
Fires after an XML node was received in receive. The <code>node</code> property contains the node that was received.
function mxSession( model, urlInit, urlPoll, urlNotify )
Constructs a new session using the given mxGraphModel and URLs to communicate with the backend.
model | mxGraphModel that contains the data. |
urlInit | URL to be used for initializing the session. |
urlPoll | URL to be used for polling the backend. |
urlNotify | URL to be used for sending changes to the backend. |
mxSession.prototype.model
Reference to the enclosing mxGraphModel.
mxSession.prototype.codec
Reference to the mxCodec used to encoding and decoding changes.
mxSession.prototype.escapePostData
Specifies if the data in the post request sent in notify should be converted using encodeURIComponent. Default is true.
mxSession.prototype.suspend = function()
Suspends the polling. Use resume to reactive the session. Fires a suspend event.
mxSession.prototype.poll = function()
Sends an asynchronous GET request to urlPoll.
mxSession.prototype.get = function( url, onLoad, onError )
Sends an asynchronous get request to the given URL, fires a get event and invokes the given onLoad function when a response is received.
mxSession.prototype.isValidResponse = function( req )
Returns true if the response data in the given mxXmlRequest is valid.
mxSession.prototype.receive = function( node )
Processes the given node by applying the changes to the model. If the nodename is state, then the namespace is used as a prefix for creating Ids in the model, and the child nodes are visited recursively. If the nodename is delta, then the changes encoded in the child nodes are applied to the model. Each call to the receive function fires a receive event with the given node as the second argument after processing. If changes are processed, then the function additionally fires a mxEvent.FIRED event before the mxEvent.RECEIVE event.
mxSession.prototype.createUndoableEdit = function( changes )
Creates a new mxUndoableEdit that implements the notify function to fire a <change> and notify event via the model.
Suspends the polling.
mxSession.prototype.suspend = function()
Resumes the session if it has been suspended.
mxSession.prototype.resume = function( type, attr, value )
Stops the session and fires a disconnect event.
mxSession.prototype.stop = function( reason )
Sends out the specified XML to urlNotify and fires a notify event.
mxSession.prototype.notify = function( xml, onLoad, onError )
Sends an asynchronous get request to the given URL, fires a get event and invokes the given onLoad function when a response is received.
mxSession.prototype.get = function( url, onLoad, onError )
Processes the given node by applying the changes to the model.
mxSession.prototype.receive = function( node )
Constructs a new session using the given mxGraphModel and URLs to communicate with the backend.
function mxSession( model, urlInit, urlPoll, urlNotify )
Reference to the enclosing mxGraphModel.
mxSession.prototype.model
URL to initialize the session.
mxSession.prototype.urlInit
URL for polling the backend.
mxSession.prototype.urlPoll
URL to send changes to the backend.
mxSession.prototype.urlNotify
Reference to the mxCodec used to encoding and decoding changes.
mxSession.prototype.codec
Used for encoding linefeeds.
mxSession.prototype.linefeed
Specifies if the data in the post request sent in notify should be converted using encodeURIComponent.
mxSession.prototype.escapePostData
Whether remote changes should be significant in the local command history.
mxSession.prototype.significantRemoteChanges
Total number of sent bytes.
mxSession.prototype.sent
Total number of received bytes.
mxSession.prototype.received
Specifies if the session should run in debug mode.
mxSession.prototype.debug
mxSession.prototype.connected
mxSession.prototype.polling
mxSession.prototype.start = function()
Sends an asynchronous GET request to urlPoll.
mxSession.prototype.poll = function()
Returns true if the response data in the given mxXmlRequest is valid.
mxSession.prototype.isValidResponse = function( req )
Returns the XML representation for the given array of changes.
mxSession.prototype.encodeChanges = function( changes, invert )
Processes the given state node which contains the current state of the remote model.
mxSession.prototype.processState = function( node )
Processes the given delta node which contains a sequence of edits which in turn map to one transaction on the remote model each.
mxSession.prototype.processDelta = function( node )
Processes the given edit by executing its changes and firing the required events via the model.
mxSession.prototype.processEdit = function( node )
Creates a new mxUndoableEdit that implements the notify function to fire a change and notify event via the model.
mxSession.prototype.createUndoableEdit = function( changes )
Decodes and executes the changes represented by the children in the given node.
mxSession.prototype.decodeChanges = function( node )
Adds removed cells to the codec object lookup for references to the removed cells after this point in time.
mxSession.prototype.cellRemoved = function( cell, codec )