Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
723 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var JSON3 = require('json3')
|
---|
4 | , iframeUtils = require('./utils/iframe')
|
---|
5 | ;
|
---|
6 |
|
---|
7 | function FacadeJS(transport) {
|
---|
8 | this._transport = transport;
|
---|
9 | transport.on('message', this._transportMessage.bind(this));
|
---|
10 | transport.on('close', this._transportClose.bind(this));
|
---|
11 | }
|
---|
12 |
|
---|
13 | FacadeJS.prototype._transportClose = function(code, reason) {
|
---|
14 | iframeUtils.postMessage('c', JSON3.stringify([code, reason]));
|
---|
15 | };
|
---|
16 | FacadeJS.prototype._transportMessage = function(frame) {
|
---|
17 | iframeUtils.postMessage('t', frame);
|
---|
18 | };
|
---|
19 | FacadeJS.prototype._send = function(data) {
|
---|
20 | this._transport.send(data);
|
---|
21 | };
|
---|
22 | FacadeJS.prototype._close = function() {
|
---|
23 | this._transport.close();
|
---|
24 | this._transport.removeAllListeners();
|
---|
25 | };
|
---|
26 |
|
---|
27 | module.exports = FacadeJS;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.