JGraph X 1.3.0.0

## com.mxgraph.sharing
Class mxSession

    java.lang.Object
      com.mxgraph.sharing.mxSession

All Implemented Interfaces:
  mxSharedDiagram.mxDiagramChangeListener

    public class mxSession

extends java.lang.Object
implements mxSharedDiagram.mxDiagramChangeListener

Implements a session that may be attached to a shared diagram.

Field Summary
`protected java.lang.StringBuffer` `buffer` Holds the send buffer for this session.
`static int` `DEFAULT_TIMEOUT` Default timeout is 10000 ms.
`protected mxSharedDiagram` `diagram` Reference to the shared diagram.
`protected java.lang.String` `id` Holds the session ID.
`protected long` `lastTimeMillis` Holds the last active time millis.

Constructor Summary
`mxSession(java.lang.String id, mxSharedDiagram diagram)` Constructs a new session with the given ID.

Method Summary
`void` `destroy()` Destroys the session and removes its listener from the shared diagram.
`void` `diagramChanged(java.lang.Object sender, java.lang.String xml)` Fires when the shared diagram was changed.
`java.lang.String` `getId()` Returns the session ID.
`java.lang.String` `getInitialState()` Returns an XML string that represents the current state of the session and the shared diagram.
`long` `inactiveTimeMillis()` Returns the number of milliseconds this session has been inactive.
`java.lang.String` `init()` Initializes the session buffer and returns a string that represents the state of the session.
`java.lang.String` `poll()` Returns the changes received by other sessions for the shared diagram.
`java.lang.String` `poll(long timeout)` Returns the changes received by other sessions for the shared diagram.
`void` `post(java.lang.String xml)` Posts the change represented by the given XML string to the shared diagram.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_TIMEOUT

    public static int DEFAULT_TIMEOUT

  Default timeout is 10000 ms.

### id

    protected java.lang.String id

  Holds the session ID.

### diagram

    protected mxSharedDiagram diagram

  Reference to the shared diagram.

### buffer

    protected java.lang.StringBuffer buffer

  Holds the send buffer for this session.

### lastTimeMillis

    protected long lastTimeMillis

  Holds the last active time millis.

Constructor Detail

### mxSession

    public mxSession(java.lang.String id,
                     mxSharedDiagram diagram)

  Constructs a new session with the given ID.

  Parameters:
    `id` - Specifies the session ID to be used.
    `diagram` - Reference to the shared diagram.

Method Detail

### getId

    public java.lang.String getId()

  Returns the session ID.

### getInitialState

    public java.lang.String getInitialState()

  Returns an XML string that represents the current state of the session and the shared diagram. A globally unique ID is used as the session's namespace, which is used on the client side to prefix IDs of newly created cells.

### init

    public java.lang.String init()

  Initializes the session buffer and returns a string that represents the state of the session.

  Returns:
    Returns the initial state of the session.

### post

    public void post(java.lang.String xml)

  Posts the change represented by the given XML string to the shared diagram.

  Parameters:
    `xml` - XML string that represents the change.

### poll

    public java.lang.String poll()
                          throws java.lang.InterruptedException

  Returns the changes received by other sessions for the shared diagram. The method returns an empty XML node if no change was received within 10 seconds.

  Returns:
    Returns a string representing the changes to the shared diagram.
  Throws:
    `java.lang.InterruptedException`

### poll

    public java.lang.String poll(long timeout)
                          throws java.lang.InterruptedException

  Returns the changes received by other sessions for the shared diagram. The method returns an empty XML node if no change was received within the given timeout.

  Parameters:
    `timeout` - Time in milliseconds to wait for changes.
  Returns:
    Returns a string representing the changes to the shared diagram.
  Throws:
    `java.lang.InterruptedException`

### inactiveTimeMillis

    public long inactiveTimeMillis()

  Returns the number of milliseconds this session has been inactive.

### diagramChanged

    public void diagramChanged(java.lang.Object sender,
                               java.lang.String xml)

  Description copied from interface: `mxSharedDiagram.mxDiagramChangeListener`
  Fires when the shared diagram was changed.

  Specified by:
    `diagramChanged` in interface `mxSharedDiagram.mxDiagramChangeListener`
  Parameters:
    `sender` - Session where the change was received from.
    `xml` - XML string that represents the change.

### destroy

    public void destroy()

  Destroys the session and removes its listener from the shared diagram.

JGraph X 1.3.0.0

Copyright (c) 2008 Gaudenz Alder. All rights reserved.