/
Launch Graph Manager


CLASS

WebSocketTransport

public class WebSocketTransport

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

Properties

delegate

public weak var delegate: WebSocketTransportDelegate?

clientName

public var clientName: String

NOTE: Setting this won't override immediately if the socket is still connected, only on reconnection.

clientVersion

public var clientVersion: String

NOTE: Setting this won't override immediately if the socket is still connected, only on reconnection.

security

public var security: SSLTrustValidator?

enableSOCKSProxy

public var enableSOCKSProxy: Bool

Determines whether a SOCKS proxy is enabled on the underlying request. Mostly useful for debugging with tools like Charles Proxy. Note: Will return false from the getter and no-op the setter for implementations that do not conform to SOCKSProxyable.

Methods

init(request:clientName:clientVersion:sendOperationIdentifiers:reconnect:reconnectionInterval:allowSendingDuplicates:connectingPayload:requestCreator:)

public init(request: URLRequest,
            clientName: String = WebSocketTransport.defaultClientName,
            clientVersion: String = WebSocketTransport.defaultClientVersion,
            sendOperationIdentifiers: Bool = false,
            reconnect: Bool = true,
            reconnectionInterval: TimeInterval = 0.5,
            allowSendingDuplicates: Bool = true,
            connectingPayload: GraphQLMap? = [:],
            requestCreator: RequestCreator = ApolloRequestCreator())

Designated initializer

  • Parameter request: The connection URLRequest
  • Parameter clientName: The client name to use for this client. Defaults to Self.defaultClientName
  • Parameter clientVersion: The client version to use for this client. Defaults to Self.defaultClientVersion.
  • Parameter sendOperationIdentifiers: Whether or not to send operation identifiers with operations. Defaults to false.
  • Parameter reconnect: Whether to auto reconnect when websocket looses connection. Defaults to true.
  • Parameter reconnectionInterval: How long to wait before attempting to reconnect. Defaults to half a second.
  • Parameter allowSendingDuplicates: Allow sending duplicate messages. Important when reconnected. Defaults to true.
  • Parameter connectingPayload: [optional] The payload to send on connection. Defaults to an empty GraphQLMap.
  • Parameter requestCreator: The request creator to use when serializing requests. Defaults to an ApolloRequestCreator.

Parameters

NameDescription
requestThe connection URLRequest
clientNameThe client name to use for this client. Defaults to Self.defaultClientName
clientVersionThe client version to use for this client. Defaults to Self.defaultClientVersion.
sendOperationIdentifiersWhether or not to send operation identifiers with operations. Defaults to false.
reconnectWhether to auto reconnect when websocket looses connection. Defaults to true.
reconnectionIntervalHow long to wait before attempting to reconnect. Defaults to half a second.
allowSendingDuplicatesAllow sending duplicate messages. Important when reconnected. Defaults to true.
connectingPayload[optional] The payload to send on connection. Defaults to an empty GraphQLMap.
requestCreatorThe request creator to use when serializing requests. Defaults to an ApolloRequestCreator.

isConnected()

public func isConnected() -> Bool

ping(data:completionHandler:)

public func ping(data: Data, completionHandler: (() -> Void)? = nil)

initServer()

public func initServer()

closeConnection()

public func closeConnection()

deinit

deinit

unsubscribe(_:)

public func unsubscribe(_ subscriptionId: String)
Edit on GitHub