Skip to content

Commit 0d14294

Browse files
committed
Add faqs page
1 parent 54c2b3b commit 0d14294

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{
5757
- Supports TLS/SSL
5858
- Can be used from Objective-C
5959
60+
## FAQS
61+
Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/FAQS.html) for commonly asked questions.
62+
6063
## Installation
6164
Requires Swift 3/Xcode 8.x
6265

Socket.IO-Client-Swift.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
74DA217D1F0945E9009C19EE /* libcommonCrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcommonCrypto.tbd; path = usr/lib/system/libcommonCrypto.tbd; sourceTree = SDKROOT; };
242242
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
243243
CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = "<group>"; };
244+
DD52BA265A22022906AF006D /* FAQ.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = FAQ.md; path = "Usage Docs/FAQ.md"; sourceTree = "<group>"; };
244245
/* End PBXFileReference section */
245246

246247
/* Begin PBXFrameworksBuildPhase section */
@@ -309,6 +310,7 @@
309310
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */,
310311
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */,
311312
5764DF7B1B51F24A004FF46E /* Source */,
313+
DD52BA265A22022906AF006D /* FAQ.md */,
312314
);
313315
sourceTree = "<group>";
314316
};

Usage Docs/FAQ.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## How do I connect to my WebSocket server?
2+
3+
This library is **NOT** a WebSockets library. This library is only for servers that implement the socket.io protocol,
4+
such as [socket.io](https://socket.io/). If you need a plain WebSockets client check out
5+
[Starscream](https://github.com/daltoniam/Starscream) for Swift and [JetFire](https://github.com/acmacalister/jetfire)
6+
for Objective-C.
7+
8+
## Why isn't my event handler being called?
9+
10+
One of the most common reasons your event might not be called is if the client is released by
11+
[ARC](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html).
12+
13+
Take this code for example:
14+
15+
```swift
16+
class SocketManager {
17+
func addHandlers() {
18+
let socket = SocketIOClient(socketURL: "http://somesocketioserver.com")
19+
20+
socket.on("myEvent") {data, ack in
21+
print(data)
22+
}
23+
}
24+
25+
}
26+
```
27+
28+
This code is **incorrect**, and the event handler will never be called. Because as soon as this method is called `socket`
29+
will be released and its memory reclaimed.
30+
31+
A correct way would be:
32+
33+
```swift
34+
class SocketManager {
35+
let socket = SocketIOClient(socketURL: "http://somesocketioserver.com")
36+
37+
func addHandlers() {
38+
socket.on("myEvent") {data, ack in
39+
print(data)
40+
}
41+
}
42+
}
43+
44+
```

0 commit comments

Comments
 (0)