Interface PushNotificationSerializer<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An adapter to send arbitrary types over the Designer/Client's "push notification" API, allowing the gateway to
initiate actions out of band. Look in the
ClientReqSession
and GatewaySessionManager
classes for
broadcast functionality.-
Method Summary
Modifier and TypeMethodDescriptionstatic PushNotificationSerializer<String>
asString()
Serializes a push notification as a UTF-8 encoded string.static <T> PushNotificationSerializer<T>
Serializes a push notification via some string-capable encoding mechanism (such as GSON/JSON), then sends it viaasString()
.void
serialize
(T notification, @NotNull OutputStream destination) Serializes a push notification into the provided output stream.
-
Method Details
-
serialize
void serialize(@Nullable T notification, @NotNull @NotNull OutputStream destination) throws IOException Serializes a push notification into the provided output stream.- Parameters:
notification
- The notification to serialize; possibly null. It is up to your serializer to decide how to encode (and, inPushNotificationDeserializer.deserialize(InputStream)
, decode) a null value.destination
- The output stream to write the serialized data to.- Throws:
IOException
- If serialization fails, or if there is some issue writing to the stream.
-
asString
Serializes a push notification as a UTF-8 encoded string. If null is sent, a special sentinel null value is written, to be separately read as a null value during deserialization. -
ofString
Serializes a push notification via some string-capable encoding mechanism (such as GSON/JSON), then sends it viaasString()
.- Parameters:
encoder
- A function that can turn your arbitrary type into a string.- See Also:
-