From 0d14294d7917fd3ed650d35cfe974a66b033ae92 Mon Sep 17 00:00:00 2001 From: Erik Little Date: Thu, 17 Aug 2017 12:38:10 -0400 Subject: [PATCH 1/2] Add faqs page --- README.md | 3 ++ .../project.pbxproj | 2 + Usage Docs/FAQ.md | 44 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 Usage Docs/FAQ.md diff --git a/README.md b/README.md index 8b01fae..a51ef86 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{ - Supports TLS/SSL - Can be used from Objective-C +## FAQS +Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/FAQS.html) for commonly asked questions. + ## Installation Requires Swift 3/Xcode 8.x diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index 0a79938..22b8236 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -241,6 +241,7 @@ 74DA217D1F0945E9009C19EE /* libcommonCrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcommonCrypto.tbd; path = usr/lib/system/libcommonCrypto.tbd; sourceTree = SDKROOT; }; 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = ""; }; CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = ""; }; + DD52BA265A22022906AF006D /* FAQ.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = FAQ.md; path = "Usage Docs/FAQ.md"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -309,6 +310,7 @@ 572EF2391B51F18A00EEBB58 /* SocketIO-Mac */, 572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */, 5764DF7B1B51F24A004FF46E /* Source */, + DD52BA265A22022906AF006D /* FAQ.md */, ); sourceTree = ""; }; diff --git a/Usage Docs/FAQ.md b/Usage Docs/FAQ.md new file mode 100644 index 0000000..a073439 --- /dev/null +++ b/Usage Docs/FAQ.md @@ -0,0 +1,44 @@ +## How do I connect to my WebSocket server? + +This library is **NOT** a WebSockets library. This library is only for servers that implement the socket.io protocol, +such as [socket.io](https://socket.io/). If you need a plain WebSockets client check out +[Starscream](https://github.com/daltoniam/Starscream) for Swift and [JetFire](https://github.com/acmacalister/jetfire) +for Objective-C. + +## Why isn't my event handler being called? + +One of the most common reasons your event might not be called is if the client is released by +[ARC](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html). + +Take this code for example: + +```swift +class SocketManager { + func addHandlers() { + let socket = SocketIOClient(socketURL: "http://somesocketioserver.com") + + socket.on("myEvent") {data, ack in + print(data) + } + } + +} +``` + +This code is **incorrect**, and the event handler will never be called. Because as soon as this method is called `socket` +will be released and its memory reclaimed. + +A correct way would be: + +```swift +class SocketManager { + let socket = SocketIOClient(socketURL: "http://somesocketioserver.com") + + func addHandlers() { + socket.on("myEvent") {data, ack in + print(data) + } + } +} + +``` From 60b7beefa5001db745cf4954ab9cd333f5745f89 Mon Sep 17 00:00:00 2001 From: Erik Little Date: Thu, 17 Aug 2017 12:45:49 -0400 Subject: [PATCH 2/2] update docs --- README.md | 2 +- docs/Classes.html | 8 + docs/Classes/OnAckCallback.html | 8 + docs/Classes/SocketAckEmitter.html | 8 + docs/Classes/SocketAnyEvent.html | 8 + docs/Classes/SocketClientManager.html | 8 + docs/Classes/SocketEngine.html | 8 + docs/Classes/SocketIOClient.html | 8 + docs/Enums.html | 8 + docs/Enums/SocketAckStatus.html | 8 + docs/Enums/SocketClientEvent.html | 8 + docs/Enums/SocketEnginePacketType.html | 8 + docs/Enums/SocketIOClientOption.html | 8 + docs/Enums/SocketIOClientStatus.html | 8 + docs/Guides.html | 164 +++++++++++++++ docs/Protocols.html | 8 + docs/Protocols/SocketData.html | 8 + docs/Protocols/SocketEngineClient.html | 8 + docs/Protocols/SocketEnginePollable.html | 8 + docs/Protocols/SocketEngineSpec.html | 8 + docs/Protocols/SocketEngineWebsocket.html | 8 + docs/Protocols/SocketLogger.html | 8 + docs/Structs.html | 8 + docs/Structs/SocketIOClientConfiguration.html | 8 + docs/Typealiases.html | 8 + docs/faq.html | 198 ++++++++++++++++++ docs/index.html | 11 + docs/search.json | 2 +- 28 files changed, 559 insertions(+), 2 deletions(-) create mode 100644 docs/Guides.html create mode 100644 docs/faq.html diff --git a/README.md b/README.md index a51ef86..7aa24d2 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{ - Can be used from Objective-C ## FAQS -Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/FAQS.html) for commonly asked questions. +Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/faq.html) for commonly asked questions. ## Installation Requires Swift 3/Xcode 8.x diff --git a/docs/Classes.html b/docs/Classes.html index ded2f40..f9265bf 100644 --- a/docs/Classes.html +++ b/docs/Classes.html @@ -43,6 +43,14 @@