new WindowSession()
Windows sesstion client is used to store the status of a inter window communication process.
Stores information about the other window e.g. (identification, status etc).
- Source:
Members
(static) CLOSED
CLOSED status means that the other window is not available.
- Source:
(static) READY
READY status means that the window is ready to receive data.
The message gets READY when it receives an ready message from the peer window.
Messages sent before reaching READY state are queued and send only after the session reaches this state.
- Source:
(static) WAITING
WAITING status means that the window is open but the ready message was not received.
While the window is waiting all messages are stored in a queue waiting for a ready message.
- Source:
allowdomain :String
Domains allowed for this session messages.
Type:
- String
- Source:
counter :Number
Counter of messages exchanged between the sessions.
Increased everytime a message is sent.
Type:
- Number
- Source:
gateway :WindowSession
The session object that is used as gateway for this session.
When directly connected to the other window has a null value.
Type:
- Source:
manager :WindowManager
The manager attached to this session.
Type:
- Source:
onBroadcastMessage :function
On broadcast message callback, receives data and authentication as parameters.
Called when a broadcast message arrives, onBroadcastMessage(data, authentication).
Type:
- function
- Source:
onClosed :function
On ready callback, called when the session enters the CLOSED state.
This callback does not receive any parameter.
Type:
- function
- Source:
onMessage :function
On message callback, receives data and authentication as parameters.
Called when a normal message is received from another window, onMessage(data, authentication).
Type:
- function
- Source:
onReady :function
On ready callback, called when the session enters the READY state.
This callback does not receive any parameter.
Type:
- function
- Source:
queue :Array
Messages waiting to be sent.
When the status is set to WAITING the messages are held here until it gets to READY status.
Type:
- Array
- Source:
received :Array
List of all messages received.
Stored the original WindowMessage object contains information about the window of origin and authentication data.
Type:
- Array
- Source:
status :String
Status of the communication.
Type:
- String
- Source:
type :String
Textual type indicator of the other window, used to indetify the type of the other window.
(e.g. "3D", "Main", etc)
Type:
- String
- Source:
url :String
URL of the other window.
Only available for windows that were open direclty, for wich a URL is known.
Type:
- String
- Source:
uuid :String
UUID to identify the other window.
Type:
- String
- Source:
window :Object
Window object of this client, is not always the actual window, but it is the window that contains (directly or indirectly) access to the destination.
The window object is used as a point of communcation. Depending of security configurations the access may be restricted.
Type:
- Object
- Source:
Methods
acknowledge()
Send a message to indicate that this session is READY.
Also sends the session metadata for the remote window.
- Source:
close(closeWindow)
Close this session, send a close message and is possible close the window.
Parameters:
Name | Type | Description |
---|---|---|
closeWindow |
Boolean | If set true the session window will be closed (if possible). |
- Source:
connect()
Used to indicate the connection intent to remote windows after a positive lookup response.
Works similarly to the ready message.
- Source:
send(action, data, authentication)
Post data to another window, windows references are stored using their url for later usage.
If the window is unknonwn the opener window is used if available.
Parameters:
Name | Type | Description |
---|---|---|
action |
String | Name of the action of this message. |
data |
Object | Data to be sent (Optional). |
authentication |
String | Authentication information (Optional). |
- Source:
sendMessage(data, authentication)
Send a message to another window, if the session is in WAITING status the message will be queued to be send later.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Data to be sent (Optional). |
authentication |
String | Authentication information (Optional). |
- Source:
setStatus(status)
Set the status of the window.
Ensures the correct order of the status being set.
Parameters:
Name | Type | Description |
---|---|---|
status |
Number |
- Source:
waitReady(onReady)
Wait for this window to be ready.
When a window is ready it should send a message containing a action property set to WindowMessage.READY.
Parameters:
Name | Type | Description |
---|---|---|
onReady |
function | Callback called when the winow is ready. |
- Source: