public interface Channel extends ChannelStatusNotifier
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BYTEARRAY_BODY_HEADER |
static long |
DEFAULT_TIME_TO_LIVE |
static java.lang.String |
RECONNECT_INTERVAL_MS_KEY |
static java.lang.String |
RECONNECT_MAX_ATTEMPTS_KEY |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ChannelStatusListener listener) |
void |
bindStatus(ChannelStatusNotifier notifier) |
java.lang.String |
getClientId()
Internal client id received from the server on the first ping
|
Credentials |
getCredentials()
Current security credentials for this channel
|
long |
getDefaultTimeToLive()
Default time to live for messages sent from this channel
|
java.lang.String |
getId()
Channel identifier
|
Transport |
getTransport()
Transport used by this channel
|
<D> D |
getTransportData()
Internal data object that can be used by a transport to store channel-specific state
|
java.net.URI |
getUri()
Server application uri
|
boolean |
isAuthenticated()
True if the channel has been authenticated (exchange of a login message)
|
boolean |
isStarted() |
ResponseMessageFuture |
logout(boolean sendLogout,
ResponseListener... listeners)
Logout from the server application.
|
ResponseMessageFuture |
logout(ResponseListener... listeners)
Logout from the server application
Equivalent to
logout(boolean,org.granite.client.messaging.ResponseListener...) with sendLogout true |
void |
onCancelled(TransportMessage message)
Callback method called by the transport when a message send is cancelled
|
void |
onDisconnect()
Callback method called by the transport when it is disconnecting
|
void |
onError(TransportMessage message,
java.lang.Exception e)
Callback method called by the transport when an exception occurs during communication
|
void |
onMessage(TransportMessage message,
java.io.InputStream is)
Callback method called by the transport when a message is received
|
void |
removeListener(ChannelStatusListener listener) |
ResponseMessageFuture |
send(RequestMessage request,
ResponseListener... listeners)
Send a message on this channel
|
void |
setCredentials(Credentials credentials)
Set the security credentials for this channel
Once the credentials are set, the next
send(org.granite.client.messaging.messages.RequestMessage, org.granite.client.messaging.ResponseListener...) will trigger the authentication with the server |
void |
setDefaultTimeToLive(long defaultTimeToLive)
Set the default time to live for messages sent from this channel
|
void |
setTransportData(java.lang.Object data)
Set the channel-specific state object for the transport
|
boolean |
start()
Start the channel.
|
boolean |
stop()
Stop the channel
|
void |
unbindStatus(ChannelStatusNotifier notifier) |
static final java.lang.String RECONNECT_INTERVAL_MS_KEY
static final java.lang.String RECONNECT_MAX_ATTEMPTS_KEY
static final long DEFAULT_TIME_TO_LIVE
static final java.lang.String BYTEARRAY_BODY_HEADER
Transport getTransport()
java.lang.String getId()
java.net.URI getUri()
java.lang.String getClientId()
long getDefaultTimeToLive()
void setDefaultTimeToLive(long defaultTimeToLive)
defaultTimeToLive - default time to liveboolean start()
boolean isStarted()
boolean stop()
void setCredentials(Credentials credentials)
send(org.granite.client.messaging.messages.RequestMessage, org.granite.client.messaging.ResponseListener...) will trigger the authentication with the servercredentials - credentialsCredentials getCredentials()
boolean isAuthenticated()
ResponseMessageFuture send(RequestMessage request, ResponseListener... listeners)
request - message to sendlisteners - array of listeners to notify asynchronously when the response is receivedResponseMessageFuture logout(ResponseListener... listeners)
logout(boolean,org.granite.client.messaging.ResponseListener...) with sendLogout truelisteners - array of listeners to notify asynchronously when the response is receivedResponseMessageFuture logout(boolean sendLogout, ResponseListener... listeners)
sendLogout - if true a logout message will be sentlisteners - array of listeners to notify asynchronously when the response is received<D> D getTransportData()
D - type of transport datavoid setTransportData(java.lang.Object data)
data - transport state objectvoid onMessage(TransportMessage message, java.io.InputStream is)
is - data input stream of the incoming messagevoid onDisconnect()
void onError(TransportMessage message, java.lang.Exception e)
message - message triggering the errore - exception throws during send of messagevoid onCancelled(TransportMessage message)
message - message cancelledvoid bindStatus(ChannelStatusNotifier notifier)
void unbindStatus(ChannelStatusNotifier notifier)
void addListener(ChannelStatusListener listener)
addListener in interface ChannelStatusNotifiervoid removeListener(ChannelStatusListener listener)
removeListener in interface ChannelStatusNotifier