ByteBuffer

struct ByteBuffer
  • Read a websocket error code from a byte buffer.

    This method increments the reader index.

    Declaration

    Swift

    mutating func readWebSocketErrorCode() -> WebSocketErrorCode?

    Return Value

    The error code, or nil if there were not enough readable bytes.

  • Get a websocket error code from a byte buffer.

    This method does not increment the reader index, and may be used to read an error code from outside the readable range of bytes.

    Declaration

    Swift

    func getWebSocketErrorCode(at index: Int) -> WebSocketErrorCode?

    Parameters

    index

    The index into the buffer to read the error code from.

    Return Value

    The error code, or nil if there were not enough bytes at that index.

  • Write the given error code to the buffer.

    Declaration

    Swift

    mutating func write(webSocketErrorCode code: WebSocketErrorCode)

    Parameters

    code

    The code to write into the buffer.

  • Applies the WebSocket unmasking operation.

    Declaration

    Swift

    mutating func webSocketUnmask(_ maskingKey: WebSocketMaskingKey, indexOffset: Int = 0)

    Parameters

    maskingKey

    The masking key.

  • Applies the websocket masking operation.

    Declaration

    Swift

    mutating func webSocketMask(_ maskingKey: WebSocketMaskingKey, indexOffset: Int = 0)

    Parameters

    maskingKey

    The masking key.

    indexOffset

    An integer offset to apply to the index into the masking key. This is used when masking multiple contiguous byte buffers, to ensure that the masking key is applied uniformly to the collection rather than from the start each time.