More documentation

This commit is contained in:
Erik Little 2017-09-30 10:24:40 -04:00
parent 5607280836
commit 486a89d407
No known key found for this signature in database
GPG Key ID: 4930B7C5FBC1A69D
2 changed files with 24 additions and 1 deletions

View File

@ -24,6 +24,8 @@
import Dispatch import Dispatch
/// Defines the interface for a SocketIOClient.
protocol SocketIOClientSpec : class { protocol SocketIOClientSpec : class {
/// The queue that all interaction with the client must be on. /// The queue that all interaction with the client must be on.
var handleQueue: DispatchQueue { get set } var handleQueue: DispatchQueue { get set }

View File

@ -22,8 +22,20 @@
import Foundation import Foundation
/// Defines that a type will be able to parse socket.io-protocol messages.
protocol SocketParsable { protocol SocketParsable {
/// Called when the engine has received some binary data that should be attached to a packet.
///
/// Packets binary data should be sent directly after the packet that expects it, so there's confusion over
/// where the data should go. Data should be received in the order it is sent, so that the correct data is put
/// into the correct placeholder.
///
/// - parameter data: The data that should be attached to a packet.
func parseBinaryData(_ data: Data) func parseBinaryData(_ data: Data)
/// Called when the engine has received a string that should be parsed into a socket.io packet.
///
/// - parameter message: The string that needs parsing.
func parseSocketMessage(_ message: String) func parseSocketMessage(_ message: String)
} }
@ -133,7 +145,9 @@ extension SocketParsable where Self: SocketIOClientSpec {
} }
} }
// Parses messages recieved /// Called when the engine has received a string that should be parsed into a socket.io packet.
///
/// - parameter message: The string that needs parsing.
func parseSocketMessage(_ message: String) { func parseSocketMessage(_ message: String) {
guard !message.isEmpty else { return } guard !message.isEmpty else { return }
@ -150,6 +164,13 @@ extension SocketParsable where Self: SocketIOClientSpec {
} }
} }
/// Called when the engine has received some binary data that should be attached to a packet.
///
/// Packets binary data should be sent directly after the packet that expects it, so there's confusion over
/// where the data should go. Data should be received in the order it is sent, so that the correct data is put
/// into the correct placeholder.
///
/// - parameter data: The data that should be attached to a packet.
func parseBinaryData(_ data: Data) { func parseBinaryData(_ data: Data) {
guard !waitingPackets.isEmpty else { guard !waitingPackets.isEmpty else {
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser") DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")