SwitcherConnections
public protocol SwitcherConnections
Interact with connections to a switcher.
Used to send messages to all connected controllers and to attach message handlers to incoming Messages.
Handlers are functions that will be executed when a certain type of Message is received by the Switcher.
-
Queues a message to be sent to all connected controllers.
The message will be serialized immediately into a byte array and appended to the outgoing buffer of all the connected controllers. These buffers will be flushed after at most 20ms.
Declaration
Swift
func send(_ message: SerializableMessage) -
Attaches a message handler to a concrete
Messagetype. Every time a message of this type comes in, the providedhandlerwill be called with two parameters: the message itself and the origin of the message. The handler takes one generic argumentmessage. The type of this argument indicates the type that this message handler will be attached to.Declaration
Swift
func when<M>(_ handler: @escaping (_ message: M, _ context: ConnectionState) -> Void) where M : DeserializableMessageParameters
handlerThe handler to attach
messageThe message to which the handler is attached
contextThe origin of the message. Use this parameter to reply directly to the sender of the message.
View on GitHub
SwitcherConnections Protocol Reference