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
key
The Pusher app key
socket
The websocket object
url
The URL the connection is made to
options
A PusherClientOptions instance containing all of the user-specified client options
URLSession
An 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
event
The name of the event
data
The data to be stringified and sent
channel
The 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
error
The 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
event
The 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
connection
The websocket that has received the message
string
The message received over the websocket
-
Delegate method called when a pong is received over a websocket
Declaration
Swift
public func webSocketDidReceivePong(connection: WebSocketConnection)
Parameters
connection
The 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
connection
The websocket that disconnected
closeCode
The closure code for the websocket connection.
reason
Optional 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
connection
The 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 }