SocketParsable

public protocol SocketParsable : AnyObject

Defines that a type will be able to parse socket.io-protocol messages.

Methods

  • 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.

    Declaration

    Swift

    func parseBinaryData(_ data: Data) -> SocketPacket?

    Parameters

    data

    The data that should be attached to a packet.

  • Called when the engine has received a string that should be parsed into a socket.io packet.

    Declaration

    Swift

    func parseSocketMessage(_ message: String) -> SocketPacket?

    Parameters

    message

    The string that needs parsing.

    Return Value

    A completed socket packet if there is no more data left to collect.

Available where Self: SocketManagerSpec & SocketDataBufferable

  • parseSocketMessage(_:) Default implementation

    Default Implementation

    Called when the engine has received a string that should be parsed into a socket.io packet.

    Declaration

    Swift

    func parseSocketMessage(_ message: String) -> SocketPacket?

    Parameters

    message

    The string that needs parsing.

    Return Value

    A completed socket packet or nil if the packet is invalid.

  • parseBinaryData(_:) Default implementation

    Default Implementation

    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.

    Declaration

    Swift

    func parseBinaryData(_ data: Data) -> SocketPacket?

    Parameters

    data

    The data that should be attached to a packet.

    Return Value

    A completed socket packet if there is no more data left to collect.