------=_Part_3194251_135392542.1365790423090
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Hello everyone,
we just introduced support for cross-window (cross-origin, a.k.a. cross-domain)
communication that can be utilized by UI plugins.
Custom content contributed by the UI plugin (e.g. via tab or dialog) can send arbitrary
messages back to given plugin(s) via WebAdmin (parent) window. The implementation is based
on HTML5 window.postMessage API that triggers 'message' events on the target
window. WebAdmin takes care of intercepting such messages, performing source origin check
per each plugin, and passing message data to plugin(s) as appropriate.
With this feature, custom content can directly and transparently control/notify given UI
plugin(s). Aside from content --> plugin message passing, the message data received by
the plugin also contains reference to source window, i.e. custom content that sent the
message. This can be used to establish two-way communication between custom content window
and plugin code.
For example, custom HTML content contributed by the plugin uses JavaScript to send the
message:
// 'parent' refers to WebAdmin window.
// Most browsers support sending String messages, e.g. 'Foo Bar'.
// Modern browsers support sending Object messages, e.g.
{'foo':'bar'}.
// The second argument is target origin that should match WebAdmin (Engine) origin.
// You can also use '*' (any origin) as per HTML5 spec, however this is not a
good practice.
parent.postMessage('Foo Bar', 'http://engine-host:1234');
Sample UI plugin that receives the message:
<snippet>
var api = parent.pluginApi('showcase');
// New bootstrap sequence function: provide custom API options object.
// This is completely optional, there are always sensible fallback values.
api.options({
// Specify allowed source origin(s) from which messages will be accepted.
// Can be either string (single origin) or string array (multiple origins).
// Can be '*' (any origin) as per HTML5 spec, however this is not a good
practice.
// Default value is empty array (reject all messages).
allowedMessageOrigins:
['http://content-host:80','http://content-host:443']
});
api.register({
UiInit: function() {
// Assume the dialog content takes care of sending the message.
api.showDialog(...);
},
// New event handler function: process message event.
// Called *only* after passing source origin check, based on
'allowedMessageOrigins'.
MessageReceived: function(data, sourceWindow) {
// Parse and interpret data
// Optionally, interact with sourceWindow (content that sent the message)
}
});
api.ready();
</snippet>
Attached you can find a sample UI plugin that demonstrates this new feature via custom
dialog.
Regards,
Vojtech
------=_Part_3194251_135392542.1365790423090
Content-Type: application/x-compressed-tar;
name=sample-cross-window-messaging-plugin.tar.gz
Content-Disposition: attachment;
filename=sample-cross-window-messaging-plugin.tar.gz
Content-Transfer-Encoding: base64
H4sIAGdOaFEAA+2X34/aOBDHeYW/ws2L4bqQHxuSigLS9dqT+lBt1e6pOp36YBID3oY4sh0ot+J/
v3GcbOnuIvZHtVV1/vDgZDIe2zOTb4QkqyKj/URwKfsblqd8019RKcmC5Yt+kZUwuq3H4QFxPDRj
FH431rT8wD+FX+j7Qcvz49jzW2j4yHXvRCkVEQi11vJfnsjDfsee/6LIu9RfLvkmIZL25yyj8t7t
UNV7eLz+gRfG/in4BUEUhLb+T8G96j+4kDy//xq6wFEYHqy/H0VQfy8+PfX9YVjVPwyGLeT9+OPe
5H9e/8tOp+3kZEWdEXKaOjsnYCxFpm3uhs5IuoIuuLq41hWuzqAaLNUqqyYKKnkpEvqeqOV+VKMe
Tqez6/zsU1saHqL/3+p9tzWOvP8+cE3/wyj07fv/FIyfvT774/zv92+Qrue0M24GSlIYZCJYoZDa
FnSCFf2q3AuyJsaKp6Ada0geKRiaoIIImquBaZnfC9bFTdvg3kvwBK8BLxTjuexedtpt10XvyBeK
ZCkoUhzJgiZsvkWm+8BO85QKxAWDeF3ZQ0sqKMwjWcY3NH1n3M6qx3KE/sFLpYqR6/pBPPDg5+OT
G6bRi9jz8OdOe3e1JUEXTCoqqj39xd7mTI3QvMwTvdNuD2lz5ahP85qRjC+6+JxKhcwNPkGQGKn6
6dXtHSTTOPcLLlV93up90rNfeF7xVV9E1QVstN3ega626xN/oAlla5ru7TIlipwgo7qfqne43rd5
oQcko0J18Y0AGD1Heq5Z4/uskHTb1bdj11QbmsGtm2LG0+107FaDtlYd87Mb2fIgHqL/B5r34BpH
9T8aNvofVfYghv+CVv+fgsfqf6NBaEGV0eJaMwVVpchRypNypb8L8PxNRvXlq+3btIuNruPeYE2y
koIA7V7uh9Pq/1EJaMJateqwzVcGeq95gP/kHL0iAjRzbxO9W0OezS5ooo6GvMRzzvEIzyDq7taw
N2URcuZPP9Es4avqe7b3jXgGPr72KMA9IzOaoTkXE8fkwJmeEwFLILPGaOxWLtMxy4uyzr2jc+8g
ll5NQlXeJs5vjt5C0USflUrBWXmeZCz5MnFuyaMz/QhGZKyoNoOcVzOPBruWwTqYsR4MZr8VFovF
YrFYLBaLxWKxWCwWi8Xy1PwHbpTX7gAoAAA=
------=_Part_3194251_135392542.1365790423090--