ABSDKWebSocketTransport

public class ABSDKWebSocketTransport : NetworkTransport

A network transport that uses web sockets requests to send GraphQL subscription operations to a server, and that uses the SwiftPhoenixClient implementation of Phoenix client.

  • Initialize a websocket network transport

    Declaration

    Swift

    public init(url: URL, params: [String : String]? = nil)

    Parameters

    url

    Websocket url

    params

    Parameters for the socket connection

    Return Value

    The websocket network transport

  • The socket connection status

    Declaration

    Swift

    public func isConnected() -> Bool

    Return Value

    If the socket is connected

  • Send an subscription request

    Declaration

    Swift

    public func send<Operation>(operation: Operation, completionHandler: @escaping (_ response: GraphQLResponse<Operation>?, _ error: Error?) -> Void) -> Cancellable

    Parameters

    operation

    The subscription to send

    resultHandler

    An optional closure that is called when mutation results are available or when an error occurs.

    Return Value

    An object that can be used to cancel the subscription.

  • Unsubscribe a subscription

    Declaration

    Swift

    public func unsubscribe(subscriptionSeqNo: String, handlerSeqNo: String)

    Parameters

    subscriptionSeqNo

    The sequence number of a subscription

    handlerSeqNo

    The sequence number of the handler

  • Close the socket connection and reset the state

    Declaration

    Swift

    public func closeConnection()