Skip to content

Commit 186807d

Browse files
fix conform changes with specs
1 parent 8db5692 commit 186807d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

Source/SocketIO/Client/SocketIOClientSpec.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ public protocol SocketIOClientSpec : AnyObject {
5656

5757
/// The id of this socket.io connect. This is different from the sid of the engine.io connection.
5858
var sid: String? { get }
59+
/// The id of this socket.io connect for connection state recovery.
60+
var pid: String? { get }
61+
62+
/// Offset of last socket.io event for connection state recovery.
63+
var lastEventOffset: String? { get }
64+
/// Boolean setted after connection to know if socket state is recovered or not.
65+
var recovered: Bool { get }
66+
67+
/// Array of events (or binary events) to handle when socket is connected and recover packets from server
68+
var savedEvents: [SocketPacket] { get }
5969

6070
/// The status of this client.
6171
var status: SocketIOStatus { get }
@@ -192,6 +202,17 @@ public protocol SocketIOClientSpec : AnyObject {
192202
/// - parameter packet: The packet to handle.
193203
func handlePacket(_ packet: SocketPacket)
194204

205+
/// Called when we get an event from socket.io
206+
/// Save it to event array if an event is sent before socket is set to connected status.
207+
/// Do not save event if pid is nil (cannot recover events from server)
208+
///
209+
/// - parameter packet: The packet to handle.
210+
/// - parameter isInternalMessage: Whether this event was sent internally. If `true` ignore it.
211+
func saveEventPacketIfNeeded(packet: SocketPacket, isInternalMessage: Bool)
212+
213+
/// Called when socket pass to connected state, handle events if socket recover data from server
214+
func handleSavedEventPackets()
215+
195216
/// Call when you wish to leave a namespace and disconnect this socket.
196217
func leaveNamespace()
197218

Source/SocketIO/Engine/SocketEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate,
340340
/// - parameter reason: The reason for the disconnection. This is communicated up to the client.
341341
open func close(reason: String) {
342342
guard connected && !closed else { return closeOutEngine(reason: reason) }
343-
DefaultSocketLogger.Logger.log("Engine is being foce closed.", type: SocketEngine.logType)
343+
DefaultSocketLogger.Logger.log("Engine is being force closed.", type: SocketEngine.logType)
344344
closeOutEngine(reason: reason)
345345
}
346346

Source/SocketIO/Manager/SocketManagerSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public protocol SocketManagerSpec : SocketEngineClient {
105105
/// Disconnects the manager and all associated sockets.
106106
func disconnect()
107107

108-
/// Foce disconnects the manager and all associated sockets.
108+
/// Force disconnects the manager and all associated sockets.
109109
func close()
110110

111111
/// Disconnects the given socket.

0 commit comments

Comments
 (0)