");
+ $input.on("blur.tt", function($e) {
+ var active, isActive, hasActive;
+ active = document.activeElement;
+ isActive = $menu.is(active);
+ hasActive = $menu.has(active).length > 0;
+ if (_.isMsie() && (isActive || hasActive)) {
+ $e.preventDefault();
+ $e.stopImmediatePropagation();
+ _.defer(function() {
+ $input.focus();
+ });
+ }
+ });
+ $menu.on("mousedown.tt", function($e) {
+ $e.preventDefault();
+ });
+ },
+ _onSelectableClicked: function onSelectableClicked(type, $el) {
+ this.select($el);
+ },
+ _onDatasetCleared: function onDatasetCleared() {
+ this._updateHint();
+ },
+ _onDatasetRendered: function onDatasetRendered(type, dataset, suggestions, async) {
+ this._updateHint();
+ this.eventBus.trigger("render", suggestions, async, dataset);
+ },
+ _onAsyncRequested: function onAsyncRequested(type, dataset, query) {
+ this.eventBus.trigger("asyncrequest", query, dataset);
+ },
+ _onAsyncCanceled: function onAsyncCanceled(type, dataset, query) {
+ this.eventBus.trigger("asynccancel", query, dataset);
+ },
+ _onAsyncReceived: function onAsyncReceived(type, dataset, query) {
+ this.eventBus.trigger("asyncreceive", query, dataset);
+ },
+ _onFocused: function onFocused() {
+ this._minLengthMet() && this.menu.update(this.input.getQuery());
+ },
+ _onBlurred: function onBlurred() {
+ if (this.input.hasQueryChangedSinceLastFocus()) {
+ this.eventBus.trigger("change", this.input.getQuery());
+ }
+ },
+ _onEnterKeyed: function onEnterKeyed(type, $e) {
+ var $selectable;
+ if ($selectable = this.menu.getActiveSelectable()) {
+ this.select($selectable) && $e.preventDefault();
+ }
+ },
+ _onTabKeyed: function onTabKeyed(type, $e) {
+ var $selectable;
+ if ($selectable = this.menu.getActiveSelectable()) {
+ this.select($selectable) && $e.preventDefault();
+ } else if ($selectable = this.menu.getTopSelectable()) {
+ this.autocomplete($selectable) && $e.preventDefault();
+ }
+ },
+ _onEscKeyed: function onEscKeyed() {
+ this.close();
+ },
+ _onUpKeyed: function onUpKeyed() {
+ this.moveCursor(-1);
+ },
+ _onDownKeyed: function onDownKeyed() {
+ this.moveCursor(+1);
+ },
+ _onLeftKeyed: function onLeftKeyed() {
+ if (this.dir === "rtl" && this.input.isCursorAtEnd()) {
+ this.autocomplete(this.menu.getTopSelectable());
+ }
+ },
+ _onRightKeyed: function onRightKeyed() {
+ if (this.dir === "ltr" && this.input.isCursorAtEnd()) {
+ this.autocomplete(this.menu.getTopSelectable());
+ }
+ },
+ _onQueryChanged: function onQueryChanged(e, query) {
+ this._minLengthMet(query) ? this.menu.update(query) : this.menu.empty();
+ },
+ _onWhitespaceChanged: function onWhitespaceChanged() {
+ this._updateHint();
+ },
+ _onLangDirChanged: function onLangDirChanged(e, dir) {
+ if (this.dir !== dir) {
+ this.dir = dir;
+ this.menu.setLanguageDirection(dir);
+ }
+ },
+ _openIfActive: function openIfActive() {
+ this.isActive() && this.open();
+ },
+ _minLengthMet: function minLengthMet(query) {
+ query = _.isString(query) ? query : this.input.getQuery() || "";
+ return query.length >= this.minLength;
+ },
+ _updateHint: function updateHint() {
+ var $selectable, data, val, query, escapedQuery, frontMatchRegEx, match;
+ $selectable = this.menu.getTopSelectable();
+ data = this.menu.getSelectableData($selectable);
+ val = this.input.getInputValue();
+ if (data && !_.isBlankString(val) && !this.input.hasOverflow()) {
+ query = Input.normalizeQuery(val);
+ escapedQuery = _.escapeRegExChars(query);
+ frontMatchRegEx = new RegExp("^(?:" + escapedQuery + ")(.+$)", "i");
+ match = frontMatchRegEx.exec(data.val);
+ match && this.input.setHint(val + match[1]);
+ } else {
+ this.input.clearHint();
+ }
+ },
+ isEnabled: function isEnabled() {
+ return this.enabled;
+ },
+ enable: function enable() {
+ this.enabled = true;
+ },
+ disable: function disable() {
+ this.enabled = false;
+ },
+ isActive: function isActive() {
+ return this.active;
+ },
+ activate: function activate() {
+ if (this.isActive()) {
+ return true;
+ } else if (!this.isEnabled() || this.eventBus.before("active")) {
+ return false;
+ } else {
+ this.active = true;
+ this.eventBus.trigger("active");
+ return true;
+ }
+ },
+ deactivate: function deactivate() {
+ if (!this.isActive()) {
+ return true;
+ } else if (this.eventBus.before("idle")) {
+ return false;
+ } else {
+ this.active = false;
+ this.close();
+ this.eventBus.trigger("idle");
+ return true;
+ }
+ },
+ isOpen: function isOpen() {
+ return this.menu.isOpen();
+ },
+ open: function open() {
+ if (!this.isOpen() && !this.eventBus.before("open")) {
+ this.menu.open();
+ this._updateHint();
+ this.eventBus.trigger("open");
+ }
+ return this.isOpen();
+ },
+ close: function close() {
+ if (this.isOpen() && !this.eventBus.before("close")) {
+ this.menu.close();
+ this.input.clearHint();
+ this.input.resetInputValue();
+ this.eventBus.trigger("close");
+ }
+ return !this.isOpen();
+ },
+ setVal: function setVal(val) {
+ this.input.setQuery(_.toStr(val));
+ },
+ getVal: function getVal() {
+ return this.input.getQuery();
+ },
+ select: function select($selectable) {
+ var data = this.menu.getSelectableData($selectable);
+ if (data && !this.eventBus.before("select", data.obj)) {
+ this.input.setQuery(data.val, true);
+ this.eventBus.trigger("select", data.obj);
+ this.close();
+ return true;
+ }
+ return false;
+ },
+ autocomplete: function autocomplete($selectable) {
+ var query, data, isValid;
+ query = this.input.getQuery();
+ data = this.menu.getSelectableData($selectable);
+ isValid = data && query !== data.val;
+ if (isValid && !this.eventBus.before("autocomplete", data.obj)) {
+ this.input.setQuery(data.val);
+ this.eventBus.trigger("autocomplete", data.obj);
+ return true;
+ }
+ return false;
+ },
+ moveCursor: function moveCursor(delta) {
+ var query, $candidate, data, payload, cancelMove;
+ query = this.input.getQuery();
+ $candidate = this.menu.selectableRelativeToCursor(delta);
+ data = this.menu.getSelectableData($candidate);
+ payload = data ? data.obj : null;
+ cancelMove = this._minLengthMet() && this.menu.update(query);
+ if (!cancelMove && !this.eventBus.before("cursorchange", payload)) {
+ this.menu.setCursor($candidate);
+ if (data) {
+ this.input.setInputValue(data.val);
+ } else {
+ this.input.resetInputValue();
+ this._updateHint();
+ }
+ this.eventBus.trigger("cursorchange", payload);
+ return true;
+ }
+ return false;
+ },
+ destroy: function destroy() {
+ this.input.destroy();
+ this.menu.destroy();
+ }
+ });
+ return Typeahead;
+ function c(ctx) {
+ var methods = [].slice.call(arguments, 1);
+ return function() {
+ var args = [].slice.call(arguments);
+ _.each(methods, function(method) {
+ return ctx[method].apply(ctx, args);
+ });
+ };
+ }
+ }();
+ (function() {
+ "use strict";
+ var old, keys, methods;
+ old = $.fn.typeahead;
+ keys = {
+ www: "tt-www",
+ attrs: "tt-attrs",
+ typeahead: "tt-typeahead"
+ };
+ methods = {
+ initialize: function initialize(o, datasets) {
+ var www;
+ datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);
+ o = o || {};
+ www = WWW(o.classNames);
+ return this.each(attach);
+ function attach() {
+ var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, typeahead, MenuConstructor;
+ _.each(datasets, function(d) {
+ d.highlight = !!o.highlight;
+ });
+ $input = $(this);
+ $wrapper = $(www.html.wrapper);
+ $hint = $elOrNull(o.hint);
+ $menu = $elOrNull(o.menu);
+ defaultHint = o.hint !== false && !$hint;
+ defaultMenu = o.menu !== false && !$menu;
+ defaultHint && ($hint = buildHintFromInput($input, www));
+ defaultMenu && ($menu = $(www.html.menu).css(www.css.menu));
+ $hint && $hint.val("");
+ $input = prepInput($input, www);
+ if (defaultHint || defaultMenu) {
+ $wrapper.css(www.css.wrapper);
+ $input.css(defaultHint ? www.css.input : www.css.inputWithNoHint);
+ $input.wrap($wrapper).parent().prepend(defaultHint ? $hint : null).append(defaultMenu ? $menu : null);
+ }
+ MenuConstructor = defaultMenu ? DefaultMenu : Menu;
+ eventBus = new EventBus({
+ el: $input
+ });
+ input = new Input({
+ hint: $hint,
+ input: $input
+ }, www);
+ menu = new MenuConstructor({
+ node: $menu,
+ datasets: datasets
+ }, www);
+ typeahead = new Typeahead({
+ input: input,
+ menu: menu,
+ eventBus: eventBus,
+ minLength: o.minLength
+ }, www);
+ $input.data(keys.www, www);
+ $input.data(keys.typeahead, typeahead);
+ }
+ },
+ isEnabled: function isEnabled() {
+ var enabled;
+ ttEach(this.first(), function(t) {
+ enabled = t.isEnabled();
+ });
+ return enabled;
+ },
+ enable: function enable() {
+ ttEach(this, function(t) {
+ t.enable();
+ });
+ return this;
+ },
+ disable: function disable() {
+ ttEach(this, function(t) {
+ t.disable();
+ });
+ return this;
+ },
+ isActive: function isActive() {
+ var active;
+ ttEach(this.first(), function(t) {
+ active = t.isActive();
+ });
+ return active;
+ },
+ activate: function activate() {
+ ttEach(this, function(t) {
+ t.activate();
+ });
+ return this;
+ },
+ deactivate: function deactivate() {
+ ttEach(this, function(t) {
+ t.deactivate();
+ });
+ return this;
+ },
+ isOpen: function isOpen() {
+ var open;
+ ttEach(this.first(), function(t) {
+ open = t.isOpen();
+ });
+ return open;
+ },
+ open: function open() {
+ ttEach(this, function(t) {
+ t.open();
+ });
+ return this;
+ },
+ close: function close() {
+ ttEach(this, function(t) {
+ t.close();
+ });
+ return this;
+ },
+ select: function select(el) {
+ var success = false, $el = $(el);
+ ttEach(this.first(), function(t) {
+ success = t.select($el);
+ });
+ return success;
+ },
+ autocomplete: function autocomplete(el) {
+ var success = false, $el = $(el);
+ ttEach(this.first(), function(t) {
+ success = t.autocomplete($el);
+ });
+ return success;
+ },
+ moveCursor: function moveCursoe(delta) {
+ var success = false;
+ ttEach(this.first(), function(t) {
+ success = t.moveCursor(delta);
+ });
+ return success;
+ },
+ val: function val(newVal) {
+ var query;
+ if (!arguments.length) {
+ ttEach(this.first(), function(t) {
+ query = t.getVal();
+ });
+ return query;
+ } else {
+ ttEach(this, function(t) {
+ t.setVal(newVal);
+ });
+ return this;
+ }
+ },
+ destroy: function destroy() {
+ ttEach(this, function(typeahead, $input) {
+ revert($input);
+ typeahead.destroy();
+ });
+ return this;
+ }
+ };
+ $.fn.typeahead = function(method) {
+ if (methods[method]) {
+ return methods[method].apply(this, [].slice.call(arguments, 1));
+ } else {
+ return methods.initialize.apply(this, arguments);
+ }
+ };
+ $.fn.typeahead.noConflict = function noConflict() {
+ $.fn.typeahead = old;
+ return this;
+ };
+ function ttEach($els, fn) {
+ $els.each(function() {
+ var $input = $(this), typeahead;
+ (typeahead = $input.data(keys.typeahead)) && fn(typeahead, $input);
+ });
+ }
+ function buildHintFromInput($input, www) {
+ return $input.clone().addClass(www.classes.hint).removeData().css(www.css.hint).css(getBackgroundStyles($input)).prop("readonly", true).removeAttr("id name placeholder required").attr({
+ autocomplete: "off",
+ spellcheck: "false",
+ tabindex: -1
+ });
+ }
+ function prepInput($input, www) {
+ $input.data(keys.attrs, {
+ dir: $input.attr("dir"),
+ autocomplete: $input.attr("autocomplete"),
+ spellcheck: $input.attr("spellcheck"),
+ style: $input.attr("style")
+ });
+ $input.addClass(www.classes.input).attr({
+ autocomplete: "off",
+ spellcheck: false
+ });
+ try {
+ !$input.attr("dir") && $input.attr("dir", "auto");
+ } catch (e) {}
+ return $input;
+ }
+ function getBackgroundStyles($el) {
+ return {
+ backgroundAttachment: $el.css("background-attachment"),
+ backgroundClip: $el.css("background-clip"),
+ backgroundColor: $el.css("background-color"),
+ backgroundImage: $el.css("background-image"),
+ backgroundOrigin: $el.css("background-origin"),
+ backgroundPosition: $el.css("background-position"),
+ backgroundRepeat: $el.css("background-repeat"),
+ backgroundSize: $el.css("background-size")
+ };
+ }
+ function revert($input) {
+ var www, $wrapper;
+ www = $input.data(keys.www);
+ $wrapper = $input.parent().filter(www.selectors.wrapper);
+ _.each($input.data(keys.attrs), function(val, key) {
+ _.isUndefined(val) ? $input.removeAttr(key) : $input.attr(key, val);
+ });
+ $input.removeData(keys.typeahead).removeData(keys.www).removeData(keys.attr).removeClass(www.classes.input);
+ if ($wrapper.length) {
+ $input.detach().insertAfter($wrapper);
+ $wrapper.remove();
+ }
+ }
+ function $elOrNull(obj) {
+ var isValid, $el;
+ isValid = _.isJQuery(obj) || _.isElement(obj);
+ $el = isValid ? $(obj).first() : [];
+ return $el.length ? $el : null;
+ }
+ })();
+});
\ No newline at end of file
diff --git a/docs/search.json b/docs/search.json
new file mode 100644
index 0000000..62a147a
--- /dev/null
+++ b/docs/search.json
@@ -0,0 +1 @@
+{"Typealiases.html#/s:8SocketIO14NormalCallback":{"name":"NormalCallback","abstract":"
A typealias for a normal callback.
"},"Typealiases.html#/s:8SocketIO11AckCallback":{"name":"AckCallback","abstract":"
A typealias for an ack callback.
"},"Structs/SocketIOClientConfiguration.html#/s:V8SocketIO27SocketIOClientConfiguration8Iterator":{"name":"Iterator","abstract":"
Iterator type.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:V8SocketIO27SocketIOClientConfiguration7Element":{"name":"Element","abstract":"
Type of element stored.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:V8SocketIO27SocketIOClientConfiguration11SubSequence":{"name":"SubSequence","abstract":"
SubSequence type.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:V8SocketIO27SocketIOClientConfiguration5Index":{"name":"Index","abstract":"
Index type.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:vV8SocketIO27SocketIOClientConfiguration10startIndexSi":{"name":"startIndex","abstract":"
The start index of this collection.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:vV8SocketIO27SocketIOClientConfiguration8endIndexSi":{"name":"endIndex","abstract":"
The end index of this collection.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:vV8SocketIO27SocketIOClientConfiguration7isEmptySb":{"name":"isEmpty","abstract":"
Whether this collection is empty.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:vV8SocketIO27SocketIOClientConfiguration5countSi":{"name":"count","abstract":"
The number of elements stored in this collection.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:vV8SocketIO27SocketIOClientConfiguration5firstGSqOS_20SocketIOClientOption_":{"name":"first","abstract":"
The first element in this collection.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:FV8SocketIO27SocketIOClientConfigurationcFt12arrayLiteralGSaOS_20SocketIOClientOption__S0_":{"name":"init(arrayLiteral:)","abstract":"
Creates a new SocketIOClientConfiguration from an array literal.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:FV8SocketIO27SocketIOClientConfiguration12makeIteratorFT_GVs16IndexingIteratorGSaOS_20SocketIOClientOption__":{"name":"makeIterator()","abstract":"
Creates an iterator for this collection.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:FV8SocketIO27SocketIOClientConfiguration5indexFT5afterSi_Si":{"name":"index(after:)","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html#/s:FV8SocketIO27SocketIOClientConfiguration6insertFTOS_20SocketIOClientOption9replacingSb_T_":{"name":"insert(_:replacing:)","abstract":"
Special method that inserts element into the collection, replacing any other instances of element.
","parent_name":"SocketIOClientConfiguration"},"Structs/SocketIOClientConfiguration.html":{"name":"SocketIOClientConfiguration","abstract":"
An array-like type that holds SocketIOClientOptions
"},"Protocols/SSLTrustValidator.html#/s:FP8SocketIO17SSLTrustValidator7isValidFTCSo8SecTrust6domainGSqSS__Sb":{"name":"isValid(_:domain:)","abstract":"
Undocumented
","parent_name":"SSLTrustValidator"},"Protocols/SocketEngineClient.html#/s:FP8SocketIO18SocketEngineClient14engineDidErrorFT6reasonSS_T_":{"name":"engineDidError(reason:)","abstract":"
Called when the engine errors.
","parent_name":"SocketEngineClient"},"Protocols/SocketEngineClient.html#/s:FP8SocketIO18SocketEngineClient14engineDidCloseFT6reasonSS_T_":{"name":"engineDidClose(reason:)","abstract":"
Called when the engine closes.
","parent_name":"SocketEngineClient"},"Protocols/SocketEngineClient.html#/s:FP8SocketIO18SocketEngineClient13engineDidOpenFT6reasonSS_T_":{"name":"engineDidOpen(reason:)","abstract":"
Called when the engine opens.
","parent_name":"SocketEngineClient"},"Protocols/SocketEngineClient.html#/s:FP8SocketIO18SocketEngineClient18parseEngineMessageFSST_":{"name":"parseEngineMessage(_:)","abstract":"
Called when the engine has a message that must be parsed.
","parent_name":"SocketEngineClient"},"Protocols/SocketEngineClient.html#/s:FP8SocketIO18SocketEngineClient21parseEngineBinaryDataFV10Foundation4DataT_":{"name":"parseEngineBinaryData(_:)","abstract":"
Called when the engine receives binary data.
","parent_name":"SocketEngineClient"},"Protocols/WebSocketPongDelegate.html#/s:FP8SocketIO21WebSocketPongDelegate23websocketDidReceivePongFT6socketCS_9WebSocket4dataGSqV10Foundation4Data__T_":{"name":"websocketDidReceivePong(socket:data:)","abstract":"
Undocumented
","parent_name":"WebSocketPongDelegate"},"Protocols/WebSocketDelegate.html#/s:FP8SocketIO17WebSocketDelegate19websocketDidConnectFT6socketCS_9WebSocket_T_":{"name":"websocketDidConnect(socket:)","abstract":"
Undocumented
","parent_name":"WebSocketDelegate"},"Protocols/WebSocketDelegate.html#/s:FP8SocketIO17WebSocketDelegate22websocketDidDisconnectFT6socketCS_9WebSocket5errorGSqCSo7NSError__T_":{"name":"websocketDidDisconnect(socket:error:)","abstract":"
Undocumented
","parent_name":"WebSocketDelegate"},"Protocols/WebSocketDelegate.html#/s:FP8SocketIO17WebSocketDelegate26websocketDidReceiveMessageFT6socketCS_9WebSocket4textSS_T_":{"name":"websocketDidReceiveMessage(socket:text:)","abstract":"
Undocumented
","parent_name":"WebSocketDelegate"},"Protocols/WebSocketDelegate.html#/s:FP8SocketIO17WebSocketDelegate23websocketDidReceiveDataFT6socketCS_9WebSocket4dataV10Foundation4Data_T_":{"name":"websocketDidReceiveData(socket:data:)","abstract":"
Undocumented
","parent_name":"WebSocketDelegate"},"Protocols/SocketLogger.html#/s:vP8SocketIO12SocketLogger3logSb":{"name":"log","abstract":"
Whether to log or not
","parent_name":"SocketLogger"},"Protocols/SocketLogger.html#/s:FP8SocketIO12SocketLogger3logFtSS4typeSS4argsGSaP___T_":{"name":"log(_:type:args:)","abstract":"
Normal log messages
","parent_name":"SocketLogger"},"Protocols/SocketLogger.html#/s:FP8SocketIO12SocketLogger5errorFtSS4typeSS4argsGSaP___T_":{"name":"error(_:type:args:)","abstract":"
Error Messages
","parent_name":"SocketLogger"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec6clientXwGSqPS_18SocketEngineClient__":{"name":"client","abstract":"
The client for this engine.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec6closedSb":{"name":"closed","abstract":"
true if this engine is closed.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec9connectedSb":{"name":"connected","abstract":"
true if this engine is connected. Connected means that the initial poll connect has succeeded.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec13connectParamsGSqGVs10DictionarySSP___":{"name":"connectParams","abstract":"
The connect parameters sent during a connect.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec16doubleEncodeUTF8Sb":{"name":"doubleEncodeUTF8","abstract":"
Set to true if using the node.js version of socket.io. The node.js version of socket.io","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec7cookiesGSqGSaCSo10HTTPCookie__":{"name":"cookies","abstract":"
An array of HTTPCookies that are sent during the connection.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec11engineQueueCSo13DispatchQueue":{"name":"engineQueue","abstract":"
The queue that all engine actions take place on.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec12extraHeadersGSqGVs10DictionarySSSS__":{"name":"extraHeaders","abstract":"
A dictionary of extra http headers that will be set during connection.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec11fastUpgradeSb":{"name":"fastUpgrade","abstract":"
When true, the engine is in the process of switching to WebSockets.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec12forcePollingSb":{"name":"forcePolling","abstract":"
When true, the engine will only use HTTP long-polling as a transport.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec15forceWebsocketsSb":{"name":"forceWebsockets","abstract":"
When true, the engine will only use WebSockets as a transport.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec7pollingSb":{"name":"polling","abstract":"
If true, the engine is currently in HTTP long-polling mode.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec7probingSb":{"name":"probing","abstract":"
If true, the engine is currently seeing whether it can upgrade to WebSockets.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec3sidSS":{"name":"sid","abstract":"
The session id for this engine.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec10socketPathSS":{"name":"socketPath","abstract":"
The path to engine.io.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec10urlPollingV10Foundation3URL":{"name":"urlPolling","abstract":"
The url for polling.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec12urlWebSocketV10Foundation3URL":{"name":"urlWebSocket","abstract":"
The url for WebSockets.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec9websocketSb":{"name":"websocket","abstract":"
If true, then the engine is currently in WebSockets mode.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:vP8SocketIO16SocketEngineSpec2wsGSqCS_9WebSocket_":{"name":"ws","abstract":"
The WebSocket for this engine.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpeccFT6clientPS_18SocketEngineClient_3urlV10Foundation3URL7optionsGSqCSo12NSDictionary__x":{"name":"init(client:url:options:)","abstract":"
Creates a new engine.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec7connectFT_T_":{"name":"connect()","abstract":"
Starts the connection to the server.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec8didErrorFT6reasonSS_T_":{"name":"didError(reason:)","abstract":"
Called when an error happens during execution. Causes a disconnection.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec10disconnectFT6reasonSS_T_":{"name":"disconnect(reason:)","abstract":"
Disconnects from the server.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec13doFastUpgradeFT_T_":{"name":"doFastUpgrade()","abstract":"
Called to switch from HTTP long-polling to WebSockets. After calling this method the engine will be in","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec30flushWaitingForPostToWebSocketFT_T_":{"name":"flushWaitingForPostToWebSocket()","abstract":"
Causes any packets that were waiting for POSTing to be sent through the WebSocket. This happens because when","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec15parseEngineDataFV10Foundation4DataT_":{"name":"parseEngineData(_:)","abstract":"
Parses raw binary received from engine.io.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec18parseEngineMessageFTSS11fromPollingSb_T_":{"name":"parseEngineMessage(_:fromPolling:)","abstract":"
Parses a raw engine.io packet.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEngineSpec.html#/s:FP8SocketIO16SocketEngineSpec5writeFTSS8withTypeOS_22SocketEnginePacketType8withDataGSaV10Foundation4Data__T_":{"name":"write(_:withType:withData:)","abstract":"
Writes a message to engine.io, independent of transport.
","parent_name":"SocketEngineSpec"},"Protocols/SocketEnginePollable.html#/s:vP8SocketIO20SocketEnginePollable11invalidatedSb":{"name":"invalidated","abstract":"
MARK: Properties","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:vP8SocketIO20SocketEnginePollable8postWaitGSaSS_":{"name":"postWait","abstract":"
A queue of engine.io messages waiting for POSTing
","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:vP8SocketIO20SocketEnginePollable7sessionGSqCSo10URLSession_":{"name":"session","abstract":"
The URLSession that will be used for polling.
","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:vP8SocketIO20SocketEnginePollable14waitingForPollSb":{"name":"waitingForPoll","abstract":"
true if there is an outstanding poll. Trying to poll before the first is done will cause socket.io to","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:vP8SocketIO20SocketEnginePollable14waitingForPostSb":{"name":"waitingForPost","abstract":"
true if there is an outstanding post. Trying to post before the first is done will cause socket.io to","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:FP8SocketIO20SocketEnginePollable6doPollFT_T_":{"name":"doPoll()","abstract":"
Call to send a long-polling request.
","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:FP8SocketIO20SocketEnginePollable15sendPollMessageFTSS8withTypeOS_22SocketEnginePacketType8withDataGSaV10Foundation4Data__T_":{"name":"sendPollMessage(_:withType:withData:)","abstract":"
Sends an engine.io message through the polling transport.
","parent_name":"SocketEnginePollable"},"Protocols/SocketEnginePollable.html#/s:FP8SocketIO20SocketEnginePollable11stopPollingFT_T_":{"name":"stopPolling()","abstract":"
Call to stop polling and invalidate the URLSession.
","parent_name":"SocketEnginePollable"},"Protocols/SocketEngineWebsocket.html#/s:FP8SocketIO21SocketEngineWebsocket20sendWebSocketMessageFTSS8withTypeOS_22SocketEnginePacketType8withDataGSaV10Foundation4Data__T_":{"name":"sendWebSocketMessage(_:withType:withData:)","abstract":"
Sends an engine.io message through the WebSocket transport.
","parent_name":"SocketEngineWebsocket"},"Protocols/SocketEngineWebsocket.html#/s:FE8SocketIOPS_21SocketEngineWebsocket26websocketDidReceiveMessageFT6socketCS_9WebSocket4textSS_T_":{"name":"websocketDidReceiveMessage(socket:text:)","abstract":"
Delegate method for when a message is received.
","parent_name":"SocketEngineWebsocket"},"Protocols/SocketEngineWebsocket.html#/s:FE8SocketIOPS_21SocketEngineWebsocket23websocketDidReceiveDataFT6socketCS_9WebSocket4dataV10Foundation4Data_T_":{"name":"websocketDidReceiveData(socket:data:)","abstract":"
Delegate method for when binary is received.
","parent_name":"SocketEngineWebsocket"},"Protocols/SocketEngineWebsocket.html":{"name":"SocketEngineWebsocket","abstract":"
Protocol that is used to implement socket.io WebSocket support
"},"Protocols/SocketEnginePollable.html":{"name":"SocketEnginePollable","abstract":"
Protocol that is used to implement socket.io polling support
"},"Protocols/SocketEngineSpec.html":{"name":"SocketEngineSpec","abstract":"
Specifies a SocketEngine.
"},"Protocols.html#/s:P8SocketIO10SocketData":{"name":"SocketData","abstract":"
A marking protocol that says a type can be represented in a socket.io packet.
"},"Protocols/SocketLogger.html":{"name":"SocketLogger","abstract":"
Represents a class will log client events.
"},"Protocols/WebSocketDelegate.html":{"name":"WebSocketDelegate","abstract":"
Undocumented
"},"Protocols/WebSocketPongDelegate.html":{"name":"WebSocketPongDelegate","abstract":"
Undocumented
"},"Protocols/SocketEngineClient.html":{"name":"SocketEngineClient","abstract":"
Declares that a type will be a delegate to an engine.
"},"Protocols/SSLTrustValidator.html":{"name":"SSLTrustValidator","abstract":"
Undocumented
"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption13connectParamsFMS0_FGVs10DictionarySSP__S0_":{"name":"connectParams","abstract":"
A dictionary of GET parameters that will be included in the connect url.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption7cookiesFMS0_FGSaCSo10HTTPCookie_S0_":{"name":"cookies","abstract":"
An array of cookies that will be sent during the initial connection.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption16doubleEncodeUTF8FMS0_FSbS0_":{"name":"doubleEncodeUTF8","abstract":"
The node.js socket.io currently does funky things to unicode when doing HTTP long-polling. Passing true in","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption12extraHeadersFMS0_FGVs10DictionarySSSS_S0_":{"name":"extraHeaders","abstract":"
Any extra HTTP headers that should be sent during the initial connection.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption8forceNewFMS0_FSbS0_":{"name":"forceNew","abstract":"
If passed true, will cause the client to always create a new engine. Useful for debugging,","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption12forcePollingFMS0_FSbS0_":{"name":"forcePolling","abstract":"
If passed true, the only transport that will be used will be HTTP long-polling.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption15forceWebsocketsFMS0_FSbS0_":{"name":"forceWebsockets","abstract":"
If passed true, the only transport that will be used will be WebSockets.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption11handleQueueFMS0_FCSo13DispatchQueueS0_":{"name":"handleQueue","abstract":"
The queue that all interaction with the client should occur on. This is the queue that event handlers are","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption3logFMS0_FSbS0_":{"name":"log","abstract":"
If passed true, the client will log debug information. This should be turned off in production code.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption6loggerFMS0_FPS_12SocketLogger_S0_":{"name":"logger","abstract":"
Used to pass in a custom logger.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption3nspFMS0_FSSS0_":{"name":"nsp","abstract":"
The namespace that this client should connect to. Can be changed during use using the joinNamespace","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption4pathFMS0_FSSS0_":{"name":"path","abstract":"
A custom path to socket.io. Only use this if the socket.io server is configured to look for this path.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption10reconnectsFMS0_FSbS0_":{"name":"reconnects","abstract":"
If passed false, the client will not reconnect when it loses connection. Useful if you want full control","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption17reconnectAttemptsFMS0_FSiS0_":{"name":"reconnectAttempts","abstract":"
The number of times to try and reconnect before giving up. Pass -1 to never give up.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption13reconnectWaitFMS0_FSiS0_":{"name":"reconnectWait","abstract":"
The number of seconds to wait before reconnect attempts.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption6secureFMS0_FSbS0_":{"name":"secure","abstract":"
Set true if your server is using secure transports.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption8securityFMS0_FCS_11SSLSecurityS0_":{"name":"security","abstract":"
Allows you to set which certs are valid. Useful for SSL pinning.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption10selfSignedFMS0_FSbS0_":{"name":"selfSigned","abstract":"
If you’re using a self-signed set. Only use for development.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption15sessionDelegateFMS0_FPSo18URLSessionDelegate_S0_":{"name":"sessionDelegate","abstract":"
Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:FO8SocketIO20SocketIOClientOption11voipEnabledFMS0_FSbS0_":{"name":"voipEnabled","abstract":"
If passed true, the WebSocket transport will try and use voip logic to keep network connections open in","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:vO8SocketIO20SocketIOClientOption11descriptionSS":{"name":"description","abstract":"
The description of this option.
","parent_name":"SocketIOClientOption"},"Enums/SocketIOClientOption.html#/s:ZFO8SocketIO20SocketIOClientOptionoi2eeFTS0_S0__Sb":{"name":"==(_:_:)","abstract":"
Compares whether two options are the same.
","parent_name":"SocketIOClientOption"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType4openFMS0_S0_":{"name":"open","abstract":"
Open message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType5closeFMS0_S0_":{"name":"close","abstract":"
Close message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType4pingFMS0_S0_":{"name":"ping","abstract":"
Ping message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType4pongFMS0_S0_":{"name":"pong","abstract":"
Pong message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType7messageFMS0_S0_":{"name":"message","abstract":"
Regular message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType7upgradeFMS0_S0_":{"name":"upgrade","abstract":"
Upgrade message.
","parent_name":"SocketEnginePacketType"},"Enums/SocketEnginePacketType.html#/s:FO8SocketIO22SocketEnginePacketType4noopFMS0_S0_":{"name":"noop","abstract":"
NOOP.
","parent_name":"SocketEnginePacketType"},"Enums/SocketAckStatus.html#/s:FO8SocketIO15SocketAckStatus5noAckFMS0_S0_":{"name":"noAck","abstract":"
The ack timed out.
","parent_name":"SocketAckStatus"},"Enums/SocketIOClientStatus.html#/s:FO8SocketIO20SocketIOClientStatus12notConnectedFMS0_S0_":{"name":"notConnected","abstract":"
The client has never been connected. Or the client has been reset.
","parent_name":"SocketIOClientStatus"},"Enums/SocketIOClientStatus.html#/s:FO8SocketIO20SocketIOClientStatus12disconnectedFMS0_S0_":{"name":"disconnected","abstract":"
The client was once connected, but not anymore.
","parent_name":"SocketIOClientStatus"},"Enums/SocketIOClientStatus.html#/s:FO8SocketIO20SocketIOClientStatus10connectingFMS0_S0_":{"name":"connecting","abstract":"
The client is in the process of connecting.
","parent_name":"SocketIOClientStatus"},"Enums/SocketIOClientStatus.html#/s:FO8SocketIO20SocketIOClientStatus9connectedFMS0_S0_":{"name":"connected","abstract":"
The client is currently connected.
","parent_name":"SocketIOClientStatus"},"Enums/SocketIOClientStatus.html":{"name":"SocketIOClientStatus","abstract":"
Represents the state of the client.
"},"Enums/SocketAckStatus.html":{"name":"SocketAckStatus","abstract":"
The status of an ack.
"},"Enums/SocketEnginePacketType.html":{"name":"SocketEnginePacketType","abstract":"
Represents the type of engine.io packet types.
"},"Enums/SocketIOClientOption.html":{"name":"SocketIOClientOption","abstract":"
The options for a client.
"},"Global Variables.html#/s:v8SocketIO31WebsocketDidConnectNotificationSS":{"name":"WebsocketDidConnectNotification","abstract":"
Undocumented
"},"Global Variables.html#/s:v8SocketIO34WebsocketDidDisconnectNotificationSS":{"name":"WebsocketDidDisconnectNotification","abstract":"
Undocumented
"},"Global Variables.html#/s:v8SocketIO34WebsocketDisconnectionErrorKeyNameSS":{"name":"WebsocketDisconnectionErrorKeyName","abstract":"
Undocumented
"},"Classes/SocketClientManager.html#/s:iC8SocketIO19SocketClientManager9subscriptFSSGSqCS_14SocketIOClient_":{"name":"subscript(_:)","abstract":"
Gets a socket by its name.
","parent_name":"SocketClientManager"},"Classes/SocketClientManager.html#/s:ZvC8SocketIO19SocketClientManager13sharedManagerS0_":{"name":"sharedManager","abstract":"
The shared manager.
","parent_name":"SocketClientManager"},"Classes/SocketClientManager.html#/s:FC8SocketIO19SocketClientManager9addSocketFTCS_14SocketIOClient9labeledAsSS_T_":{"name":"addSocket(_:labeledAs:)","abstract":"
Adds a socket.
","parent_name":"SocketClientManager"},"Classes/SocketClientManager.html#/s:FC8SocketIO19SocketClientManager12removeSocketFT9withLabelSS_GSqCS_14SocketIOClient_":{"name":"removeSocket(withLabel:)","abstract":"
Removes a socket by a given name.
","parent_name":"SocketClientManager"},"Classes/SocketClientManager.html#/s:FC8SocketIO19SocketClientManager12removeSocketFCS_14SocketIOClientGSqS1__":{"name":"removeSocket(_:)","abstract":"
Removes a socket.
","parent_name":"SocketClientManager"},"Classes/SocketClientManager.html#/s:FC8SocketIO19SocketClientManager13removeSocketsFT_T_":{"name":"removeSockets()","abstract":"
Removes all the sockets in the manager.
","parent_name":"SocketClientManager"},"Classes/SocketAnyEvent.html#/s:vC8SocketIO14SocketAnyEvent5eventSS":{"name":"event","abstract":"
The event name.
","parent_name":"SocketAnyEvent"},"Classes/SocketAnyEvent.html#/s:vC8SocketIO14SocketAnyEvent5itemsGSqGSaP___":{"name":"items","abstract":"
The data items for this event.
","parent_name":"SocketAnyEvent"},"Classes/SocketAnyEvent.html#/s:vC8SocketIO14SocketAnyEvent11descriptionSS":{"name":"description","abstract":"
The description of this event.
","parent_name":"SocketAnyEvent"},"Classes/SSLSecurity.html#/s:vC8SocketIO11SSLSecurity11validatedDNSb":{"name":"validatedDN","abstract":"
Undocumented
","parent_name":"SSLSecurity"},"Classes/SSLSecurity.html#/s:FC8SocketIO11SSLSecuritycFT13usePublicKeysSb_S0_":{"name":"init(usePublicKeys:)","abstract":"
Use certs from main app bundle
","parent_name":"SSLSecurity"},"Classes/SSLSecurity.html#/s:FC8SocketIO11SSLSecuritycFT5certsGSaCS_7SSLCert_13usePublicKeysSb_S0_":{"name":"init(certs:usePublicKeys:)","abstract":"
Designated init
","parent_name":"SSLSecurity"},"Classes/SSLSecurity.html#/s:FC8SocketIO11SSLSecurity7isValidFTCSo8SecTrust6domainGSqSS__Sb":{"name":"isValid(_:domain:)","abstract":"
Valid the trust and domain name.
","parent_name":"SSLSecurity"},"Classes/SSLCert.html#/s:FC8SocketIO7SSLCertcFT4dataV10Foundation4Data_S0_":{"name":"init(data:)","abstract":"
Designated init for certificates
","parent_name":"SSLCert"},"Classes/SSLCert.html#/s:FC8SocketIO7SSLCertcFT3keyCSo6SecKey_S0_":{"name":"init(key:)","abstract":"
Designated init for public keys
","parent_name":"SSLCert"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode6normalFMS1_S1_":{"name":"normal","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode9goingAwayFMS1_S1_":{"name":"goingAway","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode13protocolErrorFMS1_S1_":{"name":"protocolError","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode21protocolUnhandledTypeFMS1_S1_":{"name":"protocolUnhandledType","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode16noStatusReceivedFMS1_S1_":{"name":"noStatusReceived","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode8encodingFMS1_S1_":{"name":"encoding","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode14policyViolatedFMS1_S1_":{"name":"policyViolated","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html#/s:FOC8SocketIO9WebSocket9CloseCode13messageTooBigFMS1_S1_":{"name":"messageTooBig","abstract":"
Undocumented
","parent_name":"CloseCode"},"Classes/WebSocket/CloseCode.html":{"name":"CloseCode","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:ZvC8SocketIO9WebSocket11ErrorDomainSS":{"name":"ErrorDomain","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket13callbackQueueCSo13DispatchQueue":{"name":"callbackQueue","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket8delegateXwGSqPS_17WebSocketDelegate__":{"name":"delegate","abstract":"
Responds to callback about new messages coming in over the WebSocket","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket12pongDelegateXwGSqPS_21WebSocketPongDelegate__":{"name":"pongDelegate","abstract":"
Receives a callback for each pong message recived.
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket9onConnectGSqFT_T__":{"name":"onConnect","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket12onDisconnectGSqFGSqCSo7NSError_T__":{"name":"onDisconnect","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket6onTextGSqFSST__":{"name":"onText","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket6onDataGSqFV10Foundation4DataT__":{"name":"onData","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket6onPongGSqFGSqV10Foundation4Data_T__":{"name":"onPong","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket7headersGVs10DictionarySSSS_":{"name":"headers","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket11voipEnabledSb":{"name":"voipEnabled","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket24disableSSLCertValidationSb":{"name":"disableSSLCertValidation","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket8securityGSqPS_17SSLTrustValidator__":{"name":"security","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket22enabledSSLCipherSuitesGSqGSaVs6UInt32__":{"name":"enabledSSLCipherSuites","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket6originGSqSS_":{"name":"origin","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket7timeoutSi":{"name":"timeout","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket11isConnectedSb":{"name":"isConnected","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:vC8SocketIO9WebSocket10currentURLV10Foundation3URL":{"name":"currentURL","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocketcFT3urlV10Foundation3URL9protocolsGSqGSaSS___S0_":{"name":"init(url:protocols:)","abstract":"
Used for setting protocols.
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocketcFT3urlV10Foundation3URL13writeQueueQOSOSC16QualityOfService9protocolsGSqGSaSS___S0_":{"name":"init(url:writeQueueQOS:protocols:)","abstract":"
Undocumented
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket7connectFT_T_":{"name":"connect()","abstract":"
Connect to the WebSocket server on a background thread.
","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket10disconnectFT12forceTimeoutGSqSd_9closeCodeVs6UInt16_T_":{"name":"disconnect(forceTimeout:closeCode:)","abstract":"
Disconnect from the server. I send a Close control frame to the server, then expect the server to respond with a Close control frame and close the socket from its end. I notify my delegate once the socket has been closed.","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket5writeFT6stringSS10completionGSqFT_T___T_":{"name":"write(string:completion:)","abstract":"
Write a string to the websocket. This sends it as a text frame.","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket5writeFT4dataV10Foundation4Data10completionGSqFT_T___T_":{"name":"write(data:completion:)","abstract":"
Write binary data to the websocket. This sends it as a binary frame.","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket5writeFT4pingV10Foundation4Data10completionGSqFT_T___T_":{"name":"write(ping:completion:)","abstract":"
Write a ping to the websocket. This sends it as a control frame.","parent_name":"WebSocket"},"Classes/WebSocket.html#/s:FC8SocketIO9WebSocket6streamFTCSo6Stream6handleVS1_5Event_T_":{"name":"stream(_:handle:)","abstract":"
Delegate for the stream methods. Processes incoming bytes
","parent_name":"WebSocket"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient9socketURLV10Foundation3URL":{"name":"socketURL","abstract":"
The URL of the socket.io server. This is set in the initializer.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient6engineGSqPS_16SocketEngineSpec__":{"name":"engine","abstract":"
The engine for this client.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient6statusOS_20SocketIOClientStatus":{"name":"status","abstract":"
The status of this client.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient8forceNewSb":{"name":"forceNew","abstract":"
If true then every time connect is called, a new engine will be created.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient11handleQueueCSo13DispatchQueue":{"name":"handleQueue","abstract":"
The queue that all interaction with the client should occur on. This is the queue that event handlers are","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient3nspSS":{"name":"nsp","abstract":"
The namespace for this client.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient6configVS_27SocketIOClientConfiguration":{"name":"config","abstract":"
The configuration for this client.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient10reconnectsSb":{"name":"reconnects","abstract":"
If true, this client will try and reconnect on any disconnects.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient13reconnectWaitSi":{"name":"reconnectWait","abstract":"
The number of seconds to wait before attempting to reconnect.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:vC8SocketIO14SocketIOClient3sidGSqSS_":{"name":"sid","abstract":"
The session id of this client.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClientcFT9socketURLV10Foundation3URL6configVS_27SocketIOClientConfiguration_S0_":{"name":"init(socketURL:config:)","abstract":"
Type safe way to create a new SocketIOClient. opts can be omitted.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClientcFT9socketURLCSo5NSURL6configGSqCSo12NSDictionary__S0_":{"name":"init(socketURL:config:)","abstract":"
Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient7connectFT_T_":{"name":"connect()","abstract":"
Connect to the server.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient7connectFT12timeoutAfterSi11withHandlerGSqFT_T___T_":{"name":"connect(timeoutAfter:withHandler:)","abstract":"
Connect to the server. If we aren’t connected after timeoutAfter seconds, then withHandler is called.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient10disconnectFT_T_":{"name":"disconnect()","abstract":"
Disconnects the socket.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient4emitFtSSGSaPS_10SocketData___T_":{"name":"emit(_:_:)","abstract":"
Send an event to the server, with optional data items.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient4emitFTSS4withGSaP___T_":{"name":"emit(_:with:)","abstract":"
Same as emit, but meant for Objective-C
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient11emitWithAckFtSSGSaPS_10SocketData___CS_13OnAckCallback":{"name":"emitWithAck(_:_:)","abstract":"
Sends a message to the server, requesting an ack.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient11emitWithAckFTSS4withGSaP___CS_13OnAckCallback":{"name":"emitWithAck(_:with:)","abstract":"
Same as emitWithAck, but for Objective-C
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient14engineDidCloseFT6reasonSS_T_":{"name":"engineDidClose(reason:)","abstract":"
Called when the engine closes.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient14engineDidErrorFT6reasonSS_T_":{"name":"engineDidError(reason:)","abstract":"
Called when the engine errors.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient13engineDidOpenFT6reasonSS_T_":{"name":"engineDidOpen(reason:)","abstract":"
Called when the engine opens.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient11handleEventFTSS4dataGSaP__17isInternalMessageSb7withAckSi_T_":{"name":"handleEvent(_:data:isInternalMessage:withAck:)","abstract":"
Causes an event to be handled, and any event handlers for that event to be called.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient14leaveNamespaceFT_T_":{"name":"leaveNamespace()","abstract":"
Leaves nsp and goes back to the default namespace.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient13joinNamespaceFSST_":{"name":"joinNamespace(_:)","abstract":"
Joins namespace.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient3offFSST_":{"name":"off(_:)","abstract":"
Removes handler(s) based on an event name.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient3offFT2idV10Foundation4UUID_T_":{"name":"off(id:)","abstract":"
Removes a handler with the specified UUID gotten from an on or once
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient2onFTSS8callbackFTGSaP__CS_16SocketAckEmitter_T__V10Foundation4UUID":{"name":"on(_:callback:)","abstract":"
Adds a handler for an event.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient4onceFTSS8callbackFTGSaP__CS_16SocketAckEmitter_T__V10Foundation4UUID":{"name":"once(_:callback:)","abstract":"
Adds a single-use handler for an event.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient5onAnyFFCS_14SocketAnyEventT_T_":{"name":"onAny(_:)","abstract":"
Adds a handler that will be called on every event.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient18parseEngineMessageFSST_":{"name":"parseEngineMessage(_:)","abstract":"
Called when the engine has a message that must be parsed.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient21parseEngineBinaryDataFV10Foundation4DataT_":{"name":"parseEngineBinaryData(_:)","abstract":"
Called when the engine receives binary data.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient9reconnectFT_T_":{"name":"reconnect()","abstract":"
Tries to reconnect to the server.
","parent_name":"SocketIOClient"},"Classes/SocketIOClient.html#/s:FC8SocketIO14SocketIOClient17removeAllHandlersFT_T_":{"name":"removeAllHandlers()","abstract":"
Removes all handlers.","parent_name":"SocketIOClient"},"Classes/OnAckCallback.html#/s:FC8SocketIO13OnAckCallback9timingOutFT5afterSi8callbackFGSaP__T__T_":{"name":"timingOut(after:callback:)","abstract":"
Completes an emitWithAck. If this isn’t called, the emit never happens.
","parent_name":"OnAckCallback"},"Classes/SocketAckEmitter.html#/s:vC8SocketIO16SocketAckEmitter8expectedSb":{"name":"expected","abstract":"
If true, this handler is expecting to be acked. Call with(_: SocketData...) to ack.
","parent_name":"SocketAckEmitter"},"Classes/SocketAckEmitter.html#/s:FC8SocketIO16SocketAckEmitter4withFtGSaPS_10SocketData___T_":{"name":"with(_:)","abstract":"
Call to ack receiving this event.
","parent_name":"SocketAckEmitter"},"Classes/SocketAckEmitter.html#/s:FC8SocketIO16SocketAckEmitter4withFGSaP__T_":{"name":"with(_:)","abstract":"
Call to ack receiving this event.
","parent_name":"SocketAckEmitter"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine11engineQueueCSo13DispatchQueue":{"name":"engineQueue","abstract":"
The queue that all engine actions take place on.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine13connectParamsGSqGVs10DictionarySSP___":{"name":"connectParams","abstract":"
The connect parameters sent during a connect.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine8postWaitGSaSS_":{"name":"postWait","abstract":"
A queue of engine.io messages waiting for POSTing
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine14waitingForPollSb":{"name":"waitingForPoll","abstract":"
true if there is an outstanding poll. Trying to poll before the first is done will cause socket.io to","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine14waitingForPostSb":{"name":"waitingForPost","abstract":"
true if there is an outstanding post. Trying to post before the first is done will cause socket.io to","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine6closedSb":{"name":"closed","abstract":"
true if this engine is closed.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine9connectedSb":{"name":"connected","abstract":"
true if this engine is connected. Connected means that the initial poll connect has succeeded.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine7cookiesGSqGSaCSo10HTTPCookie__":{"name":"cookies","abstract":"
An array of HTTPCookies that are sent during the connection.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine16doubleEncodeUTF8Sb":{"name":"doubleEncodeUTF8","abstract":"
Set to true if using the node.js version of socket.io. The node.js version of socket.io","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine12extraHeadersGSqGVs10DictionarySSSS__":{"name":"extraHeaders","abstract":"
A dictionary of extra http headers that will be set during connection.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine11fastUpgradeSb":{"name":"fastUpgrade","abstract":"
When true, the engine is in the process of switching to WebSockets.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine12forcePollingSb":{"name":"forcePolling","abstract":"
When true, the engine will only use HTTP long-polling as a transport.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine15forceWebsocketsSb":{"name":"forceWebsockets","abstract":"
When true, the engine will only use WebSockets as a transport.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine11invalidatedSb":{"name":"invalidated","abstract":"
true If engine’s session has been invalidated.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine7pollingSb":{"name":"polling","abstract":"
If true, the engine is currently in HTTP long-polling mode.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine7probingSb":{"name":"probing","abstract":"
If true, the engine is currently seeing whether it can upgrade to WebSockets.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine7sessionGSqCSo10URLSession_":{"name":"session","abstract":"
The URLSession that will be used for polling.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine3sidSS":{"name":"sid","abstract":"
The session id for this engine.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine10socketPathSS":{"name":"socketPath","abstract":"
The path to engine.io.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine10urlPollingV10Foundation3URL":{"name":"urlPolling","abstract":"
The url for polling.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine12urlWebSocketV10Foundation3URL":{"name":"urlWebSocket","abstract":"
The url for WebSockets.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine9websocketSb":{"name":"websocket","abstract":"
If true, then the engine is currently in WebSockets mode.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine2wsGSqCS_9WebSocket_":{"name":"ws","abstract":"
The WebSocket for this engine.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:vC8SocketIO12SocketEngine6clientXwGSqPS_18SocketEngineClient__":{"name":"client","abstract":"
The client for this engine.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEnginecFT6clientPS_18SocketEngineClient_3urlV10Foundation3URL6configVS_27SocketIOClientConfiguration_S0_":{"name":"init(client:url:config:)","abstract":"
Creates a new engine.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEnginecFT6clientPS_18SocketEngineClient_3urlV10Foundation3URL7optionsGSqCSo12NSDictionary__S0_":{"name":"init(client:url:options:)","abstract":"
Creates a new engine.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine7connectFT_T_":{"name":"connect()","abstract":"
Starts the connection to the server.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine8didErrorFT6reasonSS_T_":{"name":"didError(reason:)","abstract":"
Called when an error happens during execution. Causes a disconnection.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine10disconnectFT6reasonSS_T_":{"name":"disconnect(reason:)","abstract":"
Disconnects from the server.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine13doFastUpgradeFT_T_":{"name":"doFastUpgrade()","abstract":"
Called to switch from HTTP long-polling to WebSockets. After calling this method the engine will be in","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine30flushWaitingForPostToWebSocketFT_T_":{"name":"flushWaitingForPostToWebSocket()","abstract":"
Causes any packets that were waiting for POSTing to be sent through the WebSocket. This happens because when","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine15parseEngineDataFV10Foundation4DataT_":{"name":"parseEngineData(_:)","abstract":"
Parses raw binary received from engine.io.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine18parseEngineMessageFTSS11fromPollingSb_T_":{"name":"parseEngineMessage(_:fromPolling:)","abstract":"
Parses a raw engine.io packet.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine5writeFTSS8withTypeOS_22SocketEnginePacketType8withDataGSaV10Foundation4Data__T_":{"name":"write(_:withType:withData:)","abstract":"
Writes a message to engine.io, independent of transport.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine19websocketDidConnectFT6socketCS_9WebSocket_T_":{"name":"websocketDidConnect(socket:)","abstract":"
Delegate method for connection.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine22websocketDidDisconnectFT6socketCS_9WebSocket5errorGSqCSo7NSError__T_":{"name":"websocketDidDisconnect(socket:error:)","abstract":"
Delegate method for disconnection.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html#/s:FC8SocketIO12SocketEngine10URLSessionFT7sessionCSo10URLSession25didBecomeInvalidWithErrorGSqCSo7NSError__T_":{"name":"URLSession(session:didBecomeInvalidWithError:)","abstract":"
Delegate called when the session becomes invalid.
","parent_name":"SocketEngine"},"Classes/SocketEngine.html":{"name":"SocketEngine","abstract":"
The class that handles the engine.io protocol and transports."},"Classes/SocketAckEmitter.html":{"name":"SocketAckEmitter","abstract":"
A class that represents a waiting ack call.
"},"Classes/OnAckCallback.html":{"name":"OnAckCallback","abstract":"
A class that represents an emit that will request an ack that has not yet been sent."},"Classes/SocketIOClient.html":{"name":"SocketIOClient","abstract":"
The main class for SocketIOClientSwift.
"},"Classes/WebSocket.html":{"name":"WebSocket","abstract":"
Undocumented
"},"Classes/SSLCert.html":{"name":"SSLCert","abstract":"
Undocumented
"},"Classes/SSLSecurity.html":{"name":"SSLSecurity","abstract":"
Undocumented
"},"Classes/SocketAnyEvent.html":{"name":"SocketAnyEvent","abstract":"
Represents some event that was received.
"},"Classes/SocketClientManager.html":{"name":"SocketClientManager","abstract":"
Experimental socket manager.
"},"Classes.html":{"name":"Classes","abstract":"
The following classes are available globally.
"},"Global Variables.html":{"name":"Global Variables","abstract":"
The following global variables are available globally.
"},"Enums.html":{"name":"Enums","abstract":"
The following enums are available globally.
"},"Protocols.html":{"name":"Protocols","abstract":"
The following protocols are available globally.
"},"Structs.html":{"name":"Structs","abstract":"
The following structs are available globally.
"},"Typealiases.html":{"name":"Typealiases","abstract":"
The following typealiases are available globally.
"}}
\ No newline at end of file
From af5e934d697eefb4dae72e3979428851de485d9c Mon Sep 17 00:00:00 2001
From: Erik
Date: Sat, 6 May 2017 16:02:04 -0400
Subject: [PATCH 17/24] Implement #672
---
Source/SocketIOClient.swift | 12 +++++++--
Source/SocketTypes.swift | 53 ++++++++++++++++++++++++++++---------
2 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift
index 7892909..186c5eb 100644
--- a/Source/SocketIOClient.swift
+++ b/Source/SocketIOClient.swift
@@ -234,7 +234,11 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
/// - parameter event: The event to send.
/// - parameter items: The items to send with this event. May be left out.
open func emit(_ event: String, _ items: SocketData...) {
- emit(event, with: items)
+ do {
+ emit(event, with: try items.map({ try $0.socketRepresentation() }))
+ } catch {
+ fatalError("Error creating socketRepresentation for emit: \(event), \(items)")
+ }
}
/// Same as emit, but meant for Objective-C
@@ -267,7 +271,11 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
/// - parameter items: The items to send with this event. May be left out.
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
open func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback {
- return emitWithAck(event, with: items)
+ do {
+ return emitWithAck(event, with: try items.map({ try $0.socketRepresentation() }))
+ } catch {
+ fatalError("Error creating socketRepresentation for emit: \(event), \(items)")
+ }
}
/// Same as emitWithAck, but for Objective-C
diff --git a/Source/SocketTypes.swift b/Source/SocketTypes.swift
index b4eb203..096c250 100644
--- a/Source/SocketTypes.swift
+++ b/Source/SocketTypes.swift
@@ -25,20 +25,47 @@
import Foundation
/// A marking protocol that says a type can be represented in a socket.io packet.
-public protocol SocketData {}
+///
+/// Example:
+///
+/// ```swift
+/// struct CustomData : SocketData {
+/// let name: String
+/// let age: Int
+///
+/// func socketRepresentation() -> SocketData {
+/// return ["name": name, "age": age]
+/// }
+/// }
+///
+/// socket.emit("myEvent", CustomData(name: "Erik", age: 24))
+/// ```
+public protocol SocketData {
+ // MARK: Methods
-extension Array : SocketData {}
-extension Bool : SocketData {}
-extension Dictionary : SocketData {}
-extension Double : SocketData {}
-extension Int : SocketData {}
-extension NSArray : SocketData {}
-extension Data : SocketData {}
-extension NSData : SocketData {}
-extension NSDictionary : SocketData {}
-extension NSString : SocketData {}
-extension NSNull : SocketData {}
-extension String : SocketData {}
+ /// A representation of self that can sent over socket.io.
+ func socketRepresentation() throws -> SocketData
+}
+
+public extension SocketData {
+ /// Default implementation. Only works for native Swift types and a few Foundation types.
+ func socketRepresentation() -> SocketData {
+ return self
+ }
+}
+
+extension Array : SocketData { }
+extension Bool : SocketData { }
+extension Dictionary : SocketData { }
+extension Double : SocketData { }
+extension Int : SocketData { }
+extension NSArray : SocketData { }
+extension Data : SocketData { }
+extension NSData : SocketData { }
+extension NSDictionary : SocketData { }
+extension NSString : SocketData { }
+extension NSNull : SocketData { }
+extension String : SocketData { }
/// A typealias for an ack callback.
public typealias AckCallback = ([Any]) -> Void
From bcce3cdfe7f1337447202e429c574662c0d6d710 Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 09:54:51 -0400
Subject: [PATCH 18/24] Disable logging in tests, use xctool again
---
.travis.yml | 4 ++--
SocketIO-MacTests/SocketObjectiveCTest.m | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1c99082..27cb301 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,5 +9,5 @@ branches:
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
-# script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test -parallelize
-script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
+script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac run-tests --parallelize
+#script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
diff --git a/SocketIO-MacTests/SocketObjectiveCTest.m b/SocketIO-MacTests/SocketObjectiveCTest.m
index f35e2aa..e0edc8a 100644
--- a/SocketIO-MacTests/SocketObjectiveCTest.m
+++ b/SocketIO-MacTests/SocketObjectiveCTest.m
@@ -21,7 +21,7 @@
- (void)setUp {
[super setUp];
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"];
- self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}];
+ self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @YES}];
}
- (void)testOnSyntax {
@@ -36,7 +36,7 @@
- (void)testEmitWithAckSyntax {
[[self.socket emitWithAck:@"testAckEmit" with:@[@YES]] timingOutAfter:0 callback:^(NSArray* data) {
-
+
}];
}
From 1c1eb3d08d63e9f10e4f6684e27b7557479a632a Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 09:58:44 -0400
Subject: [PATCH 19/24] Try and fix travis
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 27cb301..3859340 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,5 +9,5 @@ branches:
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
-script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac run-tests --parallelize
+script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-MacTests run-tests --parallelize
#script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
From 77034a46feae8beb3063c0587225a52ac3e7f343 Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 10:01:45 -0400
Subject: [PATCH 20/24] Go back to straight xcodebuild
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 3859340..534185a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,5 +9,5 @@ branches:
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
-script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-MacTests run-tests --parallelize
-#script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
+#script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac run-tests --parallelize
+script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
From f10839b83265e44dce24d556f68d7621286d4c6c Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 10:10:01 -0400
Subject: [PATCH 21/24] Use xctool
---
.travis.yml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 534185a..87fa1ab 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,5 +9,7 @@ branches:
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
-#script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac run-tests --parallelize
-script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
+script:
+ - xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build-for-testing -quiet
+ - xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac run-tests --parallelize
+#script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test
From 2e492ee9bc88b29a6fc0a200ef371da57deae6b5 Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 10:33:19 -0400
Subject: [PATCH 22/24] Remove from manager can be discarded
---
Source/SocketClientManager.swift | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Source/SocketClientManager.swift b/Source/SocketClientManager.swift
index 3813cdc..db9d722 100644
--- a/Source/SocketClientManager.swift
+++ b/Source/SocketClientManager.swift
@@ -78,6 +78,7 @@ open class SocketClientManager : NSObject {
///
/// - parameter withLabel: The label of the socket to remove.
/// - returns: The socket for the given label, if one was present.
+ @discardableResult
open func removeSocket(withLabel label: String) -> SocketIOClient? {
return sockets.removeValue(forKey: label)
}
@@ -86,6 +87,7 @@ open class SocketClientManager : NSObject {
///
/// - parameter socket: The socket to remove.
/// - returns: The socket if it was in the manager.
+ @discardableResult
open func removeSocket(_ socket: SocketIOClient) -> SocketIOClient? {
var returnSocket: SocketIOClient?
From 1eb39d650aa1c7157b9f3bb62a5739d715f02a6c Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 10:52:17 -0400
Subject: [PATCH 23/24] Add client event for status changes. Closes #668
---
SocketIO-MacTests/SocketSideEffectTest.swift | 91 ++++++++++++--------
Source/SocketIOClient.swift | 6 ++
2 files changed, 62 insertions(+), 35 deletions(-)
diff --git a/SocketIO-MacTests/SocketSideEffectTest.swift b/SocketIO-MacTests/SocketSideEffectTest.swift
index 9fede35..e277aef 100644
--- a/SocketIO-MacTests/SocketSideEffectTest.swift
+++ b/SocketIO-MacTests/SocketSideEffectTest.swift
@@ -10,77 +10,67 @@ import XCTest
@testable import SocketIO
class SocketSideEffectTest: XCTestCase {
- let data = "test".data(using: String.Encoding.utf8)!
- let data2 = "test2".data(using: String.Encoding.utf8)!
- private var socket: SocketIOClient!
-
- override func setUp() {
- super.setUp()
- socket = SocketIOClient(socketURL: URL(string: "http://localhost/")!)
- socket.setTestable()
- }
-
func testInitialCurrentAck() {
XCTAssertEqual(socket.currentAck, -1)
}
-
+
func testFirstAck() {
socket.emitWithAck("test").timingOut(after: 0) {data in}
XCTAssertEqual(socket.currentAck, 0)
}
-
+
func testSecondAck() {
socket.emitWithAck("test").timingOut(after: 0) {data in}
socket.emitWithAck("test").timingOut(after: 0) {data in}
-
+
XCTAssertEqual(socket.currentAck, 1)
}
-
+
func testHandleAck() {
let expect = expectation(description: "handled ack")
socket.emitWithAck("test").timingOut(after: 0) {data in
XCTAssertEqual(data[0] as? String, "hello world")
expect.fulfill()
}
-
+
socket.parseSocketMessage("30[\"hello world\"]")
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleAck2() {
let expect = expectation(description: "handled ack2")
socket.emitWithAck("test").timingOut(after: 0) {data in
XCTAssertTrue(data.count == 2, "Wrong number of ack items")
expect.fulfill()
}
-
+
socket.parseSocketMessage("61-0[{\"_placeholder\":true,\"num\":0},{\"test\":true}]")
socket.parseBinaryData(Data())
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleEvent() {
let expect = expectation(description: "handled event")
socket.on("test") {data, ack in
XCTAssertEqual(data[0] as? String, "hello world")
expect.fulfill()
}
-
+
socket.parseSocketMessage("2[\"test\",\"hello world\"]")
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleStringEventWithQuotes() {
let expect = expectation(description: "handled event")
socket.on("test") {data, ack in
XCTAssertEqual(data[0] as? String, "\"hello world\"")
expect.fulfill()
}
-
+
socket.parseSocketMessage("2[\"test\",\"\\\"hello world\\\"\"]")
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleOnceEvent() {
let expect = expectation(description: "handled event")
socket.once("test") {data, ack in
@@ -88,11 +78,11 @@ class SocketSideEffectTest: XCTestCase {
XCTAssertEqual(self.socket.testHandlers.count, 0)
expect.fulfill()
}
-
+
socket.parseSocketMessage("2[\"test\",\"hello world\"]")
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testOffWithEvent() {
socket.on("test") {data, ack in }
XCTAssertEqual(socket.testHandlers.count, 1)
@@ -101,7 +91,7 @@ class SocketSideEffectTest: XCTestCase {
socket.off("test")
XCTAssertEqual(socket.testHandlers.count, 0)
}
-
+
func testOffWithId() {
let handler = socket.on("test") {data, ack in }
XCTAssertEqual(socket.testHandlers.count, 1)
@@ -110,7 +100,7 @@ class SocketSideEffectTest: XCTestCase {
socket.off(id: handler)
XCTAssertEqual(socket.testHandlers.count, 1)
}
-
+
func testHandlesErrorPacket() {
let expect = expectation(description: "Handled error")
socket.on("error") {data, ack in
@@ -118,11 +108,11 @@ class SocketSideEffectTest: XCTestCase {
expect.fulfill()
}
}
-
+
socket.parseSocketMessage("4\"test error\"")
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleBinaryEvent() {
let expect = expectation(description: "handled binary event")
socket.on("test") {data, ack in
@@ -131,12 +121,12 @@ class SocketSideEffectTest: XCTestCase {
expect.fulfill()
}
}
-
+
socket.parseSocketMessage("51-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0}}]")
socket.parseBinaryData(data)
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testHandleMultipleBinaryEvent() {
let expect = expectation(description: "handled multiple binary event")
socket.on("test") {data, ack in
@@ -147,22 +137,53 @@ class SocketSideEffectTest: XCTestCase {
expect.fulfill()
}
}
-
+
socket.parseSocketMessage("52-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0},\"test2\":{\"_placeholder\":true,\"num\":1}}]")
socket.parseBinaryData(data)
socket.parseBinaryData(data2)
waitForExpectations(timeout: 3, handler: nil)
}
-
+
func testSocketManager() {
let manager = SocketClientManager.sharedManager
manager["test"] = socket
-
+
XCTAssert(manager["test"] === socket, "failed to get socket")
-
+
manager["test"] = nil
-
+
XCTAssert(manager["test"] == nil, "socket not removed")
}
+
+ func testChangingStatusCallsStatusChangeHandler() {
+ let expect = expectation(description: "The client should announce when the status changes")
+ let statusChange = SocketIOClientStatus.connecting
+
+ socket.on("statusChange") {data, ack in
+ guard let status = data[0] as? SocketIOClientStatus else {
+ XCTFail("Status should be one of the defined statuses")
+
+ return
+ }
+
+ XCTAssertEqual(status, statusChange, "The status changed should be the one set")
+
+ expect.fulfill()
+ }
+
+ socket.setTestStatus(statusChange)
+
+ waitForExpectations(timeout: 0.2)
+ }
+
+ let data = "test".data(using: String.Encoding.utf8)!
+ let data2 = "test2".data(using: String.Encoding.utf8)!
+ private var socket: SocketIOClient!
+
+ override func setUp() {
+ super.setUp()
+ socket = SocketIOClient(socketURL: URL(string: "http://localhost/")!)
+ socket.setTestable()
+ }
}
diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift
index 186c5eb..384fbfd 100644
--- a/Source/SocketIOClient.swift
+++ b/Source/SocketIOClient.swift
@@ -47,6 +47,8 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
default:
break
}
+
+ handleEvent("statusChange", data: [status], isInternalMessage: true)
}
}
@@ -551,6 +553,10 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
status = .connected
}
+ func setTestStatus(_ status: SocketIOClientStatus) {
+ self.status = status
+ }
+
func setTestEngine(_ engine: SocketEngineSpec?) {
self.engine = engine
}
From 158bdfb41893de6424b31d201a765b810504d959 Mon Sep 17 00:00:00 2001
From: Erik
Date: Sun, 7 May 2017 11:32:05 -0400
Subject: [PATCH 24/24] Add enum for client events. Resolves #675
---
README.md | 2 +-
SocketIO-MacTests/SocketSideEffectTest.swift | 44 ++++++++++++++++++
Source/SocketIOClient.swift | 47 +++++++++++++++-----
Source/SocketIOClientSpec.swift | 24 +++++++++-
4 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index c472316..2e7299b 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ import SocketIO
let socket = SocketIOClient(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .forcePolling(true)])
-socket.on("connect") {data, ack in
+socket.on(clientEvent: .connect) {data, ack in
print("socket connected")
}
diff --git a/SocketIO-MacTests/SocketSideEffectTest.swift b/SocketIO-MacTests/SocketSideEffectTest.swift
index e277aef..8f24c63 100644
--- a/SocketIO-MacTests/SocketSideEffectTest.swift
+++ b/SocketIO-MacTests/SocketSideEffectTest.swift
@@ -177,6 +177,50 @@ class SocketSideEffectTest: XCTestCase {
waitForExpectations(timeout: 0.2)
}
+ func testOnClientEvent() {
+ let expect = expectation(description: "The client should call client event handlers")
+ let event = SocketClientEvent.disconnect
+ let closeReason = "testing"
+
+ socket.on(clientEvent: event) {data, ack in
+ guard let reason = data[0] as? String else {
+ XCTFail("Client should pass data for client events")
+
+ return
+ }
+
+ XCTAssertEqual(closeReason, reason, "The data should be what was sent to handleClientEvent")
+
+ expect.fulfill()
+ }
+
+ socket.handleClientEvent(event, data: [closeReason])
+
+ waitForExpectations(timeout: 0.2)
+ }
+
+ func testClientEventsAreBackwardsCompatible() {
+ let expect = expectation(description: "The client should call old style client event handlers")
+ let event = SocketClientEvent.disconnect
+ let closeReason = "testing"
+
+ socket.on("disconnect") {data, ack in
+ guard let reason = data[0] as? String else {
+ XCTFail("Client should pass data for client events")
+
+ return
+ }
+
+ XCTAssertEqual(closeReason, reason, "The data should be what was sent to handleClientEvent")
+
+ expect.fulfill()
+ }
+
+ socket.handleClientEvent(event, data: [closeReason])
+
+ waitForExpectations(timeout: 0.2)
+ }
+
let data = "test".data(using: String.Encoding.utf8)!
let data2 = "test2".data(using: String.Encoding.utf8)!
private var socket: SocketIOClient!
diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift
index 384fbfd..258c37b 100644
--- a/Source/SocketIOClient.swift
+++ b/Source/SocketIOClient.swift
@@ -48,7 +48,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
break
}
- handleEvent("statusChange", data: [status], isInternalMessage: true)
+ handleClientEvent(.statusChange, data: [status])
}
}
@@ -204,11 +204,10 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
func didConnect() {
DefaultSocketLogger.Logger.log("Socket connected", type: logType)
+
status = .connected
- // Don't handle as internal because something crazy could happen where
- // we disconnect before it's handled
- handleEvent("connect", data: [], isInternalMessage: false)
+ handleClientEvent(.connect, data: [])
}
func didDisconnect(reason: String) {
@@ -221,7 +220,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
// Make sure the engine is actually dead.
engine?.disconnect(reason: reason)
- handleEvent("disconnect", data: [reason], isInternalMessage: true)
+ handleClientEvent(.disconnect, data: [reason])
}
/// Disconnects the socket.
@@ -249,7 +248,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
/// - parameter with: The items to send with this event. May be left out.
open func emit(_ event: String, with items: [Any]) {
guard status == .connected else {
- handleEvent("error", data: ["Tried emitting \(event) when not connected"], isInternalMessage: true)
+ handleClientEvent(.error, data: ["Tried emitting \(event) when not connected"])
return
}
@@ -302,7 +301,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
func _emit(_ data: [Any], ack: Int? = nil) {
guard status == .connected else {
- handleEvent("error", data: ["Tried emitting when not connected"], isInternalMessage: true)
+ handleClientEvent(.error, data: ["Tried emitting when not connected"])
return
}
@@ -362,7 +361,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
private func _engineDidError(reason: String) {
DefaultSocketLogger.Logger.error("%@", type: logType, args: reason)
- handleEvent("error", data: [reason], isInternalMessage: true)
+ handleClientEvent(.error, data: [reason])
}
/// Called when the engine opens.
@@ -399,6 +398,10 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
}
}
+ func handleClientEvent(_ event: SocketClientEvent, data: [Any]) {
+ handleEvent(event.rawValue, data: data, isInternalMessage: true)
+ }
+
/// Leaves nsp and goes back to the default namespace.
open func leaveNamespace() {
if nsp != "/" {
@@ -458,6 +461,30 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
return handler.id
}
+ /// Adds a handler for a client event.
+ ///
+ /// Example:
+ ///
+ /// ```swift
+ /// socket.on(clientEvent: .connect) {data, ack in
+ /// ...
+ /// }
+ /// ```
+ ///
+ /// - parameter event: The event for this handler.
+ /// - parameter callback: The callback that will execute when this event is received.
+ /// - returns: A unique id for the handler that can be used to remove it.
+ @discardableResult
+ open func on(clientEvent event: SocketClientEvent, callback: @escaping NormalCallback) -> UUID {
+ DefaultSocketLogger.Logger.log("Adding handler for event: %@", type: logType, args: event)
+
+ let handler = SocketEventHandler(event: event.rawValue, id: UUID(), callback: callback)
+ handlers.append(handler)
+
+ return handler.id
+ }
+
+
/// Adds a single-use handler for an event.
///
/// - parameter event: The event name for this handler.
@@ -522,7 +549,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
guard reconnecting else { return }
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
- handleEvent("reconnect", data: [reason], isInternalMessage: true)
+ handleClientEvent(.reconnect, data: [reason])
_tryReconnect()
}
@@ -535,7 +562,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
}
DefaultSocketLogger.Logger.log("Trying to reconnect", type: logType)
- handleEvent("reconnectAttempt", data: [(reconnectAttempts - currentReconnectAttempt)], isInternalMessage: true)
+ handleClientEvent(.reconnectAttempt, data: [(reconnectAttempts - currentReconnectAttempt)])
currentReconnectAttempt += 1
connect()
diff --git a/Source/SocketIOClientSpec.swift b/Source/SocketIOClientSpec.swift
index 539c4ec..b4b99a1 100644
--- a/Source/SocketIOClientSpec.swift
+++ b/Source/SocketIOClientSpec.swift
@@ -34,6 +34,7 @@ protocol SocketIOClientSpec : class {
func didError(reason: String)
func handleAck(_ ack: Int, data: [Any])
func handleEvent(_ event: String, data: [Any], isInternalMessage: Bool, withAck ack: Int)
+ func handleClientEvent(_ event: SocketClientEvent, data: [Any])
func joinNamespace(_ namespace: String)
}
@@ -41,6 +42,27 @@ extension SocketIOClientSpec {
func didError(reason: String) {
DefaultSocketLogger.Logger.error("%@", type: "SocketIOClient", args: reason)
- handleEvent("error", data: [reason], isInternalMessage: true, withAck: -1)
+ handleClientEvent(.error, data: [reason])
}
}
+
+/// The set of events that are generated by the client.
+public enum SocketClientEvent : String {
+ /// Emitted when the client connects. This is also called on a successful reconnection.
+ case connect
+
+ /// Called when the socket has disconnected and will not attempt to try to reconnect.
+ case disconnect
+
+ /// Called when an error occurs.
+ case error
+
+ /// Called when the client begins the reconnection process.
+ case reconnect
+
+ /// Called each time the client tries to reconnect to the server.
+ case reconnectAttempt
+
+ /// Called every time there is a change in the client's status.
+ case statusChange
+}