mirror of
https://github.com/yudai/gotty.git
synced 2025-09-22 05:50:48 +02:00
Add xterm itegration
* Move to TypeScript from legacy JavaScript * Add support of xterm.js * Hterm is still available for backward compatibility
This commit is contained in:
parent
d6c98866b9
commit
8803721f3d
40 changed files with 9051 additions and 124 deletions
60
js/dist/websocket.js
vendored
Normal file
60
js/dist/websocket.js
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"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
|
Loading…
Add table
Add a link
Reference in a new issue