Event
public struct Event : EventInfoRecord, Encodable
An event to trigger on a specific Channel
(or multiple channels).
-
The channels to which the event will be sent (if publishing to multiple channels).
Declaration
Swift
public let channels: [Channel]?
-
The channel to which the event will be sent (if publishing to a single channel).
Declaration
Swift
public let channel: Channel?
-
The event name.
Declaration
Swift
public let name: String
-
This is the
Data
representation of the originaldata
parameter of either of theinit(...)
methods. The data will be encrypted if achannel
is set and itsChannelType
isencrypted
.Declaration
Swift
public let data: Data
-
A connection to which the event will not be sent.
Declaration
Swift
public let socketId: String?
-
Creates an event to be triggered on a specific
Channel
.Declaration
Swift
public init<EventData: Encodable>(name: String, data: EventData, channel: Channel, socketId: String? = nil, attributeOptions: ChannelAttributeFetchOptions = []) throws
Parameters
name
The name of the event.
data
An event data object, whose type must conform to
Encodable
.channel
The channel on which to trigger the event.
socketId
A connection to which the event will not be sent.
attributeOptions
A set of attributes that should be returned for the
channel
. -
Creates an
Event
which will be triggered on multipleChannel
instances.Throws
AnPusherError
if encoding the eventdata
fails for some reason, or ifchannels
contains any encrypted channels.Declaration
Swift
public init<EventData: Encodable>(name: String, data: EventData, channels: [Channel], socketId: String? = nil, attributeOptions: ChannelAttributeFetchOptions = []) throws
Parameters
name
The name of the event.
data
An event data object, whose type must conform to
Encodable
.channels
An array of channels on which to trigger the event.
socketId
A connection to which the event will not be sent.
attributeOptions
A set of attributes that should be returned for each channel in
channels
.
-
Declaration
Swift
public func encode(to encoder: Encoder) throws