send(_:to:completion:)
Sends a custom type to other participants in the group session.
Declaration
final func send<Message>(_ value: Message, to participants: Participants = .all, completion: @escaping ((any Error)?) -> Void) where Message : Decodable, Message : EncodableParameters
- participants:
The recipients of the message. The default value of this parameter is the set of all active participants in the session. Use the Only(_:) Swift.enum.case option to specify a subset of participants.
- completion:
The handler block to call with the results of the delivery attempt. The handler has no return value and takes a single Error parameter. The value of this parameter is
nilif delivery succeeds; otherwise, it contains an appropriate error object.
Discussion
Use this method to send data that you package into a custom class or structure. The method encodes your custom structure’s type information, and delivers the data only to message sequences of the same type.