SocketClientEvent

public enum SocketClientEvent : String

The set of events that are generated by the client.

Cases

  • Emitted when the client connects. This is also called on a successful reconnection. A connect event gets one data item: the namespace that was connected to.

    socket.on(clientEvent: .connect) {data, ack in
        guard let nsp = data[0] as? String else { return }
        // Some logic using the nsp
    }
    

    Declaration

    Swift

    case connect
  • Emitted when the socket has disconnected and will not attempt to try to reconnect.

    Usage:

    socket.on(clientEvent: .disconnect) {data, ack in
        // Some cleanup logic
    }
    

    Declaration

    Swift

    case disconnect
  • Emitted when an error occurs.

    Usage:

    socket.on(clientEvent: .error) {data, ack in
        // Some logging
    }
    

    Declaration

    Swift

    case error
  • Emitted whenever the engine sends a ping.

    Usage:

    socket.on(clientEvent: .ping) {_, _ in
      // Maybe keep track of latency?
    }
    

    Declaration

    Swift

    case ping
  • Emitted whenever the engine gets a pong.

    Usage:

    socket.on(clientEvent: .pong) {_, _ in
      // Maybe keep track of latency?
    }
    

    Declaration

    Swift

    case pong
  • Emitted when the client begins the reconnection process.

    Usage:

    socket.on(clientEvent: .reconnect) {data, ack in
        // Some reconnect event logic
    }
    

    Declaration

    Swift

    case reconnect
  • Emitted each time the client tries to reconnect to the server.

    Usage:

    socket.on(clientEvent: .reconnectAttempt) {data, ack in
        // Some reconnect attempt logging
    }
    

    Declaration

    Swift

    case reconnectAttempt
  • Emitted every time there is a change in the client’s status.

    The payload for data is [SocketIOClientStatus, Int]. Where the second item is the raw value. Use the second one if you are working in Objective-C.

    Usage:

    socket.on(clientEvent: .statusChange) {data, ack in
        // Some status changing logging
    }
    

    Declaration

    Swift

    case statusChange
  • Emitted when when upgrading the http connection to a websocket connection.

    Usage:

    socket.on(clientEvent: .websocketUpgrade) {data, ack in
        let headers = (data as [Any])[0]
        // Some header logic
    }
    

    Declaration

    Swift

    case websocketUpgrade