ContextualMessageHandler
public class ContextualMessageHandler : MessageParser
A utility to parse RawMessages and call their attached handlers within a certain context.
This class is similar to PureMessageHandler with the difference that the registered handlers are also passed a certain context in addition to the attached message. This context can be used to determine where the message comes from.
-
Undocumented
Declaration
Swift
public typealias Context = ConnectionState -
Attaches a message handler to a concrete
Messagetype. Every time a message of this type comes in, the providedhandlerwill be called. The handler takes one generic argumentmessage. The type of this argument indicates the type that this message handler will be attached to.Declaration
Swift
public func when<M>(_ handler: @escaping (_ message: M, _ context: Context) -> Void) where M : DeserializableMessageParameters
handlerThe handler to attach
messageThe message to which the handler is attached
contextThe context
messagewas sent from.
View on GitHub
ContextualMessageHandler Class Reference