SocketTransport is a class which maintains an active connection to a WebSocket server
and performs reconnection whenever needed. It also notifies the user of the socket
about disconnects and allows sending and receiving messages, mimicking the native
WebSocket API.
@constructor
@extends EventEmitter
@param {string} URL - The URL to connect to. Usually equal to something like "ws://host.tld" or "ws://host.tld/path/to/socket".
@param {Object} [options] - Options for controlling the behaviour of the transport.
function SocketTransport(URL, options) {
		if (!URL) {
			throw new Error('A WebSocket URL must be passed to the SocketTransport constructor!');
		}
		if (!(this instanceof SocketTransport)) {
			return new SocketTransport(URL, options);
		}
		/**
		 * The URL to use for connecting to the WebSocket server.
		 * Typically, it looks like "ws://host.tld/path", where path may be empty.
		 * @type {string}
		 */
		this._URL = URL;
		/**
		 * A map of options to control the transport's behaviour.
		 */
		this._options = options || {};
		/**
		 * The current socket object in use.
		 * Since WebSockets can not be re-used after they have been closed,
		 *  this reference points to the current (i.e. most recent) socket in use.
		 * @type {?external:WebSocket}
		 */
		this._socket = null;
		/**
		 * A descriptive state of the transport, for internal logic use.
		 * This controls the various state transitions.
		 * @type {string}
		 */
		this._state = 'unconnected';
		/**
		 * Whether the transport is active.
		 * True means that the user intends to be connected.
		 * False is when the user has explicitly requested a connection shutdown.
		 * Inactive transports do not attempt reconnection when closed or when an error occurs.
		 * @type {boolean}
		 */
		this._active = false;
		/**
		 * The reconnection timeout. Set when an unplanned disconnect occurs.
		 * It is cleared when _deactivate() is called.
		 */
		this._reconnectTimeout = null;
		EventEmitter2.call(this);
		
		/**
		 * We store a map of "standard listeners" - that is, functions that we are going
		 *  to be adding as event listeners on WebSocket objects.
		 * This way, we have a reference to them, so we can do .removeEventListener().
		 * @type {Object.<string,function>}
		 */
		var self = this;
		var listeners = {
			open: function() {
				self._handleOpen();
			},
			error: function(error) {
				self._handleError(error);
			},
			close: function(closeEvent) {
				self._handleDisconnect();
			},
			message: function(messageEvent) {
				self.emit('message', messageEvent.data);
			}
		};
		this._standardListeners = listeners;
		
	}