public interface ChannelService
ChannelService
allows you to manage manage two-way connections
with clients.Modifier and Type | Method and Description |
---|---|
java.lang.String |
createChannel(java.lang.String clientId)
Creates a channel associated with the provided
clientId and returns
a token that is valid for the default amount of time (2 hours) |
java.lang.String |
createChannel(java.lang.String clientId,
int durationMinutes)
Creates a channel associated with the provided
clientId and returns
a token that is valid for the specified period of time. |
ChannelMessage |
parseMessage(HttpServletRequest request)
Parse the incoming message in
request . |
ChannelPresence |
parsePresence(HttpServletRequest request)
Parse the incoming presence in
request . |
void |
sendMessage(ChannelMessage message)
Sends a
ChannelMessage to the client. |
java.lang.String createChannel(java.lang.String clientId)
clientId
and returns
a token that is valid for the default amount of time (2 hours)clientId
- A string uniquely identifying the client that will use the
returned token to connect to this channel. This string must be fewer
than 64 bytes when encoded to UTF-8.ChannelFailureException
- if there is an error encountered while
communicating with the channel service.java.lang.String createChannel(java.lang.String clientId, int durationMinutes)
clientId
and returns
a token that is valid for the specified period of time.clientId
- A string uniquely identifying the client that will use the
returned token to connect to this channel. This string must be fewer
than 64 bytes when encoded to UTF-8.durationMinutes
- the amount of time for which the returned token will
be valid, in minutes. Must be greater than zero and less than 24 * 60.ChannelFailureException
- if there is an error encountered while
communicating with the channel service.void sendMessage(ChannelMessage message)
ChannelMessage
to the client.message
- the message to be sent to all connected clients.ChannelFailureException
- if there is an error encountered while
communicating with the channel service.ChannelMessage parseMessage(HttpServletRequest request)
request
. This method should only
be called within a channel webhook.request
- the source HTTP request.ChannelMessage
.java.lang.IllegalStateException
- if the required HTTP parameters are not
present.ChannelPresence parsePresence(HttpServletRequest request) throws java.io.IOException
request
. This method should only
be called within a channel presence request handler.request
- the source HTTP request.ChannelPresence
.java.io.IOException
- if the MIME body isn't parseable.java.lang.IllegalArgumentException
- if the HTTP request doesn't conform to
expectations.