gotty/js/dist/websocket.js
Iwasaki Yudai 8803721f3d Add xterm itegration
* Move to TypeScript from legacy JavaScript
* Add support of xterm.js
* Hterm is still available for backward compatibility
2017-08-21 16:38:28 +09:00

60 lines
1.6 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ConnectionFactory = (function () {
function ConnectionFactory(url, protocols) {
this.url = url;
this.protocols = protocols;
}
;
ConnectionFactory.prototype.create = function () {
return new Connection(this.url, this.protocols);
};
;
return ConnectionFactory;
}());
exports.ConnectionFactory = ConnectionFactory;
var Connection = (function () {
function Connection(url, protocols) {
this.bare = new WebSocket(url, protocols);
}
Connection.prototype.open = function () {
// nothing todo for websocket
};
;
Connection.prototype.close = function () {
this.bare.close();
};
;
Connection.prototype.send = function (data) {
this.bare.send(data);
};
;
Connection.prototype.isOpen = function () {
if (this.bare.readyState == WebSocket.CONNECTING ||
this.bare.readyState == WebSocket.OPEN) {
return true;
}
return false;
};
Connection.prototype.onOpen = function (callback) {
this.bare.onopen = function (event) {
callback();
};
};
;
Connection.prototype.onReceive = function (callback) {
this.bare.onmessage = function (event) {
callback(event.data);
};
};
;
Connection.prototype.onClose = function (callback) {
this.bare.onclose = function (event) {
callback();
};
};
;
return Connection;
}());
exports.Connection = Connection;
//# sourceMappingURL=websocket.js.map