PusherConnection
@objcMembers
@objc
open class PusherConnection : NSObject
extension PusherConnection: WebSocketConnectionDelegate
Undocumented
-
Undocumented
Declaration
Swift
public let url: String -
Undocumented
Declaration
Swift
public let key: String -
Undocumented
Declaration
Swift
open var options: PusherClientOptions -
Undocumented
Declaration
Swift
open var globalChannel: GlobalChannel! -
Undocumented
Declaration
Swift
open var socketId: String? -
Undocumented
Declaration
Swift
open var connectionState: ConnectionState -
Undocumented
Declaration
Swift
open var channels: PusherChannels -
Undocumented
Declaration
Swift
open var socket: NWWebSocket! -
Undocumented
Declaration
Swift
open var URLSession: Foundation.URLSession -
Undocumented
Declaration
Swift
open var userDataFetcher: (() -> PusherPresenceChannelMember)? -
Undocumented
Declaration
Swift
open var reconnectAttemptsMax: Int? -
Undocumented
Declaration
Swift
open var reconnectAttempts: Int -
Undocumented
Declaration
Swift
open var maxReconnectGapInSeconds: Double? -
Undocumented
Declaration
Swift
open weak var delegate: PusherDelegate? { get set } -
Undocumented
Declaration
Swift
open var pongResponseTimeoutInterval: TimeInterval -
Undocumented
Declaration
Swift
open var activityTimeoutInterval: TimeInterval -
Initializes a new PusherConnection with an app key, websocket, URL, options and URLSession
Declaration
Swift
public init( key: String, socket: NWWebSocket, url: String, options: PusherClientOptions, URLSession: Foundation.URLSession = Foundation.URLSession.shared )Parameters
keyThe Pusher app key
socketThe websocket object
urlThe URL the connection is made to
optionsA PusherClientOptions instance containing all of the user-specified client options
URLSessionAn NSURLSession instance for the connection to use for making authentication requests
Return Value
A new PusherConnection instance
-
Either writes a string directly to the websocket with the given event name and data, or calls a client event to be sent if the event is prefixed with “client”
Declaration
Swift
open func sendEvent(event: String, data: Any, channel: PusherChannel? = nil)Parameters
eventThe name of the event
dataThe data to be stringified and sent
channelThe name of the channel
-
Disconnects the websocket
Declaration
Swift
open func disconnect() -
Establish a websocket connection
Declaration
Swift
open func connect() -
Handles incoming error
Declaration
Swift
open func handleError(error: PusherError)Parameters
errorThe incoming error to be processed
-
Handles incoming events and passes them on to be handled by the appropriate function
Declaration
Swift
open func handleEvent(event: PusherEvent)Parameters
eventThe incoming event to be processed
-
Delegate method called when a message is received over a websocket
Declaration
Swift
public func webSocketDidReceiveMessage(connection: WebSocketConnection, string: String)Parameters
connectionThe websocket that has received the message
stringThe message received over the websocket
-
Delegate method called when a pong is received over a websocket
Declaration
Swift
public func webSocketDidReceivePong(connection: WebSocketConnection)Parameters
connectionThe websocket that has received the pong
-
Delegate method called when a websocket disconnected
Declaration
Swift
public func webSocketDidDisconnect(connection: WebSocketConnection, closeCode: NWProtocolWebSocket.CloseCode, reason: Data?)Parameters
connectionThe websocket that disconnected
closeCodeThe closure code for the websocket connection.
reasonOptional further information on the connection closure.
-
Declaration
Swift
public func webSocketViabilityDidChange(connection: WebSocketConnection, isViable: Bool) -
Declaration
Swift
public func webSocketDidAttemptBetterPathMigration(result: Result<WebSocketConnection, NWError>) -
Delegate method called when a websocket connected
Declaration
Swift
public func webSocketDidConnect(connection: WebSocketConnection)Parameters
connectionThe websocket that connected
-
Declaration
Swift
public func webSocketDidReceiveMessage(connection: WebSocketConnection, data: Data) -
Declaration
Swift
public func webSocketDidReceiveError(connection: WebSocketConnection, error: NWError) -
Undocumented
Declaration
Swift
var OCReconnectAttemptsMax: NSNumber? { get set } -
Undocumented
Declaration
Swift
var OCMaxReconnectGapInSeconds: NSNumber? { get set }
View on GitHub
PusherConnection Class Reference