public abstract class ChannelBase extends EventEmitter<ChannelEvent,ChannelStateListener>
| Modifier and Type | Class and Description |
|---|---|
static interface |
ChannelBase.MessageListener
An interface whereby a client maybe notified of message on a channel.
|
EventEmitter.Filter| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
name
The name of this channel.
|
Presence |
presence
The
Presence object for this channel. |
ChannelProperties |
properties
Properties of Channel
|
ErrorInfo |
reason
Error information associated with a failed channel state.
|
ChannelState |
state
The current channel state.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
apply(ChannelStateListener listener,
ChannelEvent event,
java.lang.Object... args) |
void |
attach()
Attach to this channel.
|
void |
attach(CompletionListener listener)
Attach to this channel.
|
void |
detach()
Detach from this channel.
|
void |
detach(CompletionListener listener)
Detach from this channel.
|
void |
emit(ChannelState state,
ChannelStateListener.ChannelStateChange channelStateChange) |
ChannelMode[] |
getModes() |
java.util.Map<java.lang.String,java.lang.String> |
getParams() |
PaginatedResult<Message> |
history(Param[] params)
Obtain recent history for this channel using the REST API.
|
void |
historyAsync(Param[] params,
Callback<AsyncPaginatedResult<Message>> callback) |
void |
on(ChannelState state,
ChannelStateListener listener) |
void |
once(ChannelState state,
ChannelStateListener listener) |
void |
publish(Message message)
Publish a message on this channel.
|
void |
publish(Message[] messages)
Publish an array of messages on this channel.
|
void |
publish(Message[] messages,
CompletionListener listener)
Publish an array of messages on this channel.
|
void |
publish(Message message,
CompletionListener listener)
Publish a message on this channel.
|
void |
publish(java.lang.String name,
java.lang.Object data)
Publish a message on this channel.
|
void |
publish(java.lang.String name,
java.lang.Object data,
CompletionListener listener)
Publish a message on this channel.
|
void |
setConnected() |
void |
setConnectionClosed(ErrorInfo reason)
(RTL3b) If the connection state enters the CLOSED state, then an
ATTACHING or ATTACHED channel state will transition to DETACHED.
|
void |
setConnectionFailed(ErrorInfo reason)
If the connection state enters the FAILED state, then an ATTACHING
or ATTACHED channel state will transition to FAILED and set the
Channel#errorReason
|
void |
setOptions(ChannelOptions options)
Channel options
|
void |
setOptions(ChannelOptions options,
CompletionListener listener) |
void |
setSuspended(ErrorInfo reason,
boolean notifyStateChange)
(RTL3c) If the connection state enters the SUSPENDED state, then an
ATTACHING or ATTACHED channel state will transition to SUSPENDED.
|
void |
subscribe(ChannelBase.MessageListener listener)
Subscribe for messages on this channel.
|
void |
subscribe(java.lang.String[] names,
ChannelBase.MessageListener listener)
Subscribe for messages with an array of event names on this channel.
|
void |
subscribe(java.lang.String name,
ChannelBase.MessageListener listener)
Subscribe for messages with a specific event name on this channel.
|
void |
sync() |
void |
unsubscribe()
Unsubscribe all subscribed listeners from this channel.
|
void |
unsubscribe(ChannelBase.MessageListener listener)
Unsubscribe a previously subscribed listener from this channel.
|
void |
unsubscribe(java.lang.String[] names,
ChannelBase.MessageListener listener)
Unsubscribe a previously subscribed event listener from this channel.
|
void |
unsubscribe(java.lang.String name,
ChannelBase.MessageListener listener)
Unsubscribe a previously subscribed event listener from this channel.
|
public final java.lang.String name
public final Presence presence
Presence object for this channel. This controls this client's
presence on the channel and may also be used to obtain presence information
and change events for other members of the channel.public ChannelState state
public ErrorInfo reason
public ChannelProperties properties
public void attach()
throws AblyException
AblyExceptionpublic void attach(CompletionListener listener) throws AblyException
listener - When the channel is attached successfully or the attach fails and
the ErrorInfo error is passed as an argument to the callbackAblyExceptionpublic void detach()
throws AblyException
AblyExceptionpublic void detach(CompletionListener listener) throws AblyException
AblyExceptionpublic void sync()
throws AblyException
AblyExceptionpublic void setConnected()
public void setConnectionFailed(ErrorInfo reason)
public void setConnectionClosed(ErrorInfo reason)
public void setSuspended(ErrorInfo reason, boolean notifyStateChange)
protected void apply(ChannelStateListener listener, ChannelEvent event, java.lang.Object... args)
apply in class EventEmitter<ChannelEvent,ChannelStateListener>public void unsubscribe()
Unsubscribe all subscribed listeners from this channel.
Spec: RTL8a
public void subscribe(ChannelBase.MessageListener listener) throws AblyException
listener: - the MessageListenerAblyExceptionpublic void unsubscribe(ChannelBase.MessageListener listener)
listener: - the previously subscribed listener.public void subscribe(java.lang.String name,
ChannelBase.MessageListener listener)
throws AblyException
name: - the event namelistener: - the MessageListenerAblyExceptionpublic void unsubscribe(java.lang.String name,
ChannelBase.MessageListener listener)
name: - the event namelistener: - the previously subscribed listener.public void subscribe(java.lang.String[] names,
ChannelBase.MessageListener listener)
throws AblyException
names: - the event nameslistener: - the MessageListenerAblyExceptionpublic void unsubscribe(java.lang.String[] names,
ChannelBase.MessageListener listener)
names: - the event nameslistener: - the previously subscribed listener.public void publish(java.lang.String name,
java.lang.Object data)
throws AblyException
name: - the event namedata: - the message payloadAblyExceptionpublic void publish(Message message) throws AblyException
message: - the messageAblyExceptionpublic void publish(Message[] messages) throws AblyException
messages: - the messageAblyExceptionpublic void publish(java.lang.String name,
java.lang.Object data,
CompletionListener listener)
throws AblyException
name: - the event namedata: - the message payload. See io.ably.types.Data for supported datatypeslistener: - a listener to be notified of the outcome of this message.AblyExceptionpublic void publish(Message message, CompletionListener listener) throws AblyException
message: - the messagelistener: - a listener to be notified of the outcome of this message.AblyExceptionpublic void publish(Message[] messages, CompletionListener listener) throws AblyException
messages: - the messagelistener: - a listener to be notified of the outcome of this message.AblyExceptionpublic PaginatedResult<Message> history(Param[] params) throws AblyException
params: - the request params. See the Ably REST API
documentation for more details.AblyExceptionpublic void historyAsync(Param[] params, Callback<AsyncPaginatedResult<Message>> callback)
public void setOptions(ChannelOptions options) throws AblyException
AblyExceptionpublic void setOptions(ChannelOptions options, CompletionListener listener) throws AblyException
AblyExceptionpublic java.util.Map<java.lang.String,java.lang.String> getParams()
public ChannelMode[] getModes()
public void emit(ChannelState state, ChannelStateListener.ChannelStateChange channelStateChange)
public void on(ChannelState state, ChannelStateListener listener)
public void once(ChannelState state, ChannelStateListener listener)