Skip to content

Commit 486a89d

Browse files
committed
More documentation
1 parent 5607280 commit 486a89d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Source/SocketIO/Client/SocketIOClientSpec.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import Dispatch
2626

27+
28+
/// Defines the interface for a SocketIOClient.
2729
protocol SocketIOClientSpec : class {
2830
/// The queue that all interaction with the client must be on.
2931
var handleQueue: DispatchQueue { get set }

Source/SocketIO/Parse/SocketParsable.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,20 @@
2222

2323
import Foundation
2424

25+
/// Defines that a type will be able to parse socket.io-protocol messages.
2526
protocol SocketParsable {
27+
/// Called when the engine has received some binary data that should be attached to a packet.
28+
///
29+
/// Packets binary data should be sent directly after the packet that expects it, so there's confusion over
30+
/// where the data should go. Data should be received in the order it is sent, so that the correct data is put
31+
/// into the correct placeholder.
32+
///
33+
/// - parameter data: The data that should be attached to a packet.
2634
func parseBinaryData(_ data: Data)
35+
36+
/// Called when the engine has received a string that should be parsed into a socket.io packet.
37+
///
38+
/// - parameter message: The string that needs parsing.
2739
func parseSocketMessage(_ message: String)
2840
}
2941

@@ -133,7 +145,9 @@ extension SocketParsable where Self: SocketIOClientSpec {
133145
}
134146
}
135147

136-
// Parses messages recieved
148+
/// Called when the engine has received a string that should be parsed into a socket.io packet.
149+
///
150+
/// - parameter message: The string that needs parsing.
137151
func parseSocketMessage(_ message: String) {
138152
guard !message.isEmpty else { return }
139153

@@ -150,6 +164,13 @@ extension SocketParsable where Self: SocketIOClientSpec {
150164
}
151165
}
152166

167+
/// Called when the engine has received some binary data that should be attached to a packet.
168+
///
169+
/// Packets binary data should be sent directly after the packet that expects it, so there's confusion over
170+
/// where the data should go. Data should be received in the order it is sent, so that the correct data is put
171+
/// into the correct placeholder.
172+
///
173+
/// - parameter data: The data that should be attached to a packet.
153174
func parseBinaryData(_ data: Data) {
154175
guard !waitingPackets.isEmpty else {
155176
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")

0 commit comments

Comments
 (0)