- All Superinterfaces:
AutoCloseable
@Experimental
@NoImplement
@MinMuleVersion("4.10.0")
public interface SseClient
extends AutoCloseable
Server-side abstraction of a connected client.
- Since:
- 0.12.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection.voidThe callback will be called when the client closes its connection or there is an error sending the response.voidsendComment(String comment) Sends a comment.default voidEquivalent to callsendEvent("message", data, null, null);default voidEquivalent to callsendEvent(name, data, null, null);default voidEquivalent to callsendEvent(name, data, id, null);voidSends an event to the client represented by this interface.
-
Method Details
-
sendEvent
Sends an event to the client represented by this interface.- Parameters:
name- the event name (topic).data- the data as string.id- event id (used to resume an event stream on reconnection).retryDelay- new retry delay, in milliseconds.- Throws:
IOException
-
sendEvent
Equivalent to callsendEvent(name, data, id, null);- Parameters:
name- the event name (topic).data- the data as string.id- event id (used to resume an event stream on reconnection).- Throws:
IOException
-
sendEvent
Equivalent to callsendEvent(name, data, null, null);- Parameters:
name- the event name (topic).data- the data as string.- Throws:
IOException
-
sendEvent
Equivalent to callsendEvent("message", data, null, null);Note: If you want to send a message without a topic, you can call
sendEvent(null, data);- Parameters:
data- the data as string.- Throws:
IOException
-
sendComment
Sends a comment.- Parameters:
comment- the comment.
-
onClose
The callback will be called when the client closes its connection or there is an error sending the response.- Parameters:
callback- to be called in that situation.
-
getClientId
String getClientId()- Returns:
- unique identifier of this client.
-
getRemoteAddress
InetSocketAddress getRemoteAddress()- Returns:
- the address of the remote client.
-
close
Closes the connection.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-