diff --git a/Source/SocketIO/Client/SocketIOClient.swift b/Source/SocketIO/Client/SocketIOClient.swift index 73fc10b..697f274 100644 --- a/Source/SocketIO/Client/SocketIOClient.swift +++ b/Source/SocketIO/Client/SocketIOClient.swift @@ -463,7 +463,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So } private func _engineDidReceivePong() { - handleClientEvent(.gotPong, data: []) + handleClientEvent(.pong, data: []) } /// Called when the sends a ping to the server. @@ -474,7 +474,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So } private func _engineDidSendPing() { - handleClientEvent(.sentPing, data: []) + handleClientEvent(.ping, data: []) } /// Called when socket.io has acked one of our emits. Causes the corresponding ack callback to be called. diff --git a/Source/SocketIO/Client/SocketIOClientSpec.swift b/Source/SocketIO/Client/SocketIOClientSpec.swift index de52421..7038f7c 100644 --- a/Source/SocketIO/Client/SocketIOClientSpec.swift +++ b/Source/SocketIO/Client/SocketIOClientSpec.swift @@ -267,16 +267,27 @@ public enum SocketClientEvent : String { /// ``` case error + /// Emitted whenever the engine sends a ping. + /// + /// Usage: + /// + /// ```swift + /// socket.on(clientEvent: .ping) {_, _ in + /// // Maybe keep track of latency? + /// } + /// ``` + case ping + /// Emitted whenever the engine gets a pong. /// /// Usage: /// /// ```swift - /// socket.on(clientEvent: .gotPong) {_, _ in + /// socket.on(clientEvent: .pong) {_, _ in /// // Maybe keep track of latency? /// } /// ``` - case gotPong + case pong /// Emitted when the client begins the reconnection process. /// @@ -300,17 +311,6 @@ public enum SocketClientEvent : String { /// ``` case reconnectAttempt - /// Emitted whenever the engine sends a ping. - /// - /// Usage: - /// - /// ```swift - /// socket.on(clientEvent: .sentPing) {_, _ in - /// // Maybe keep track of latency? - /// } - /// ``` - case sentPing - /// Emitted every time there is a change in the client's status. /// /// Usage: diff --git a/Tests/TestSocketIO/SocketSideEffectTest.swift b/Tests/TestSocketIO/SocketSideEffectTest.swift index 892e848..c487dd1 100644 --- a/Tests/TestSocketIO/SocketSideEffectTest.swift +++ b/Tests/TestSocketIO/SocketSideEffectTest.swift @@ -413,9 +413,9 @@ class SocketSideEffectTest: XCTestCase { } func testClientCallsSentPingHandler() { - let expect = expectation(description: "The client should emit a sentPing event") + let expect = expectation(description: "The client should emit a ping event") - socket.on(clientEvent: .sentPing) {data, ack in + socket.on(clientEvent: .ping) {data, ack in expect.fulfill() } @@ -425,9 +425,9 @@ class SocketSideEffectTest: XCTestCase { } func testClientCallsGotPongHandler() { - let expect = expectation(description: "The client should emit a gotPong event") + let expect = expectation(description: "The client should emit a pong event") - socket.on(clientEvent: .gotPong) {data, ack in + socket.on(clientEvent: .pong) {data, ack in expect.fulfill() }