2015-02-03 21:13:27 +01:00
|
|
|
/**
|
|
|
|
* WebSocket transport. Generally needed because browsers can't handle
|
|
|
|
* TCP sockets so we proxy messages from clients via WebSocket into TCP
|
|
|
|
* data packets.
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var inherits = require("inherits");
|
|
|
|
var assert = require("../_util").assert;
|
2015-02-06 10:47:40 +01:00
|
|
|
var BaseTransport = require("./base");
|
2015-02-03 21:13:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WebSocket transport constructor.
|
|
|
|
* @constructor
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
function Transport() {
|
|
|
|
Transport.super_.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(Transport, BaseTransport);
|
|
|
|
|
|
|
|
Transport.prototype.connect = function(opts) {
|
|
|
|
assert(!this._client, "Already connected");
|
|
|
|
this._client = new WebSocket(opts);
|
|
|
|
};
|
|
|
|
|
2015-02-06 10:47:40 +01:00
|
|
|
module.exports = Transport;
|