public class Connection extends java.lang.Object implements ConnectionBase
Modifier and Type | Field and Description |
---|---|
static Version |
PROTOCOL_VERSION |
Constructor and Description |
---|
Connection(java.lang.String url)
Initializes the connection with an URL
|
Connection(java.lang.String url,
Logger logger)
Initializes the connection with an URL and a logger
|
Connection(java.lang.String url,
java.lang.String queryString)
Initializes the connection with an URL and a query string
|
Connection(java.lang.String url,
java.lang.String queryString,
Logger logger)
Initializes the connection with an URL, a query string and a Logger
|
Modifier and Type | Method and Description |
---|---|
void |
closed(java.lang.Runnable handler)
Sets the handler for the "Closed" event
|
void |
connected(java.lang.Runnable handler)
Sets the handler for the "Connected" event
|
void |
connectionSlow(java.lang.Runnable handler)
Sets the handler for the "ConnectionSlow" event
|
void |
disconnect()
Closes the connection
|
void |
error(ErrorCallback handler)
Sets the handler for the "Error" event
|
java.lang.String |
getConnectionData()
Returns the data used by the connection
|
java.lang.String |
getConnectionId()
Returns the connection Id
|
java.lang.String |
getConnectionToken()
Returns the connection token
|
Credentials |
getCredentials()
Returns the credentials used by the connection
|
java.lang.String |
getGroupsToken()
Returns the connection groups token
|
com.google.gson.Gson |
getGson()
Returns the Gson instance used by the connection
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns the connection headers
|
com.google.gson.JsonParser |
getJsonParser()
Returns the JsonParser used by the connection
|
Logger |
getLogger()
Returns the Logger used by the connection
|
java.lang.String |
getMessageId()
Returns the current message Id
|
java.lang.String |
getQueryString()
Returns the query string used by the connection
|
ConnectionState |
getState()
Returns the connection state
|
java.lang.String |
getUrl()
Returns the URL used by the connection
|
void |
onError(java.lang.Throwable error,
boolean mustCleanCurrentConnection)
Triggers the Error event
|
void |
onReceived(com.google.gson.JsonElement message) |
void |
prepareRequest(microsoft.aspnet.signalr.client.http.Request request)
Prepares a request that is going to be sent to the server
|
void |
received(MessageReceivedHandler handler)
Sets the handler for the "Received" event
|
void |
reconnected(java.lang.Runnable handler)
Sets the handler for the "Reconnected" event
|
void |
reconnecting(java.lang.Runnable handler)
Sets the handler for the "Reconnecting" event
|
SignalRFuture<java.lang.Void> |
send(java.lang.Object object)
Sends a serialized object
|
SignalRFuture<java.lang.Void> |
send(java.lang.String data)
Sends data using the connection
|
void |
setCredentials(Credentials credentials)
Sets the credentials the connection should use
|
void |
setGroupsToken(java.lang.String groupsToken)
Sets the groups token the connection should use
|
void |
setMessageId(java.lang.String messageId)
Sets the message id the connection should use
|
SignalRFuture<java.lang.Void> |
start()
Starts the connection using the best available transport
|
SignalRFuture<java.lang.Void> |
start(microsoft.aspnet.signalr.client.transport.ClientTransport transport)
Starts the connection
|
void |
stateChanged(StateChangedCallback handler)
Sets the handler for the "StateChanged" event
|
void |
stop()
Aborts the connection and closes it
|
public static final Version PROTOCOL_VERSION
public Connection(java.lang.String url)
url
- The connection URLpublic Connection(java.lang.String url, Logger logger)
url
- The connection URLlogger
- The connection loggerpublic Connection(java.lang.String url, java.lang.String queryString)
url
- The connection URLqueryString
- The connection query stringpublic Connection(java.lang.String url, java.lang.String queryString, Logger logger)
url
- The connection URLqueryString
- The connection query stringlogger
- The connection loggerpublic void closed(java.lang.Runnable handler)
ConnectionBase
closed
in interface ConnectionBase
public void connected(java.lang.Runnable handler)
ConnectionBase
connected
in interface ConnectionBase
public void connectionSlow(java.lang.Runnable handler)
ConnectionBase
connectionSlow
in interface ConnectionBase
public void disconnect()
ConnectionBase
disconnect
in interface ConnectionBase
public void error(ErrorCallback handler)
ConnectionBase
error
in interface ConnectionBase
public java.lang.String getConnectionData()
ConnectionBase
getConnectionData
in interface ConnectionBase
public java.lang.String getConnectionId()
ConnectionBase
getConnectionId
in interface ConnectionBase
public java.lang.String getConnectionToken()
ConnectionBase
getConnectionToken
in interface ConnectionBase
public Credentials getCredentials()
ConnectionBase
getCredentials
in interface ConnectionBase
public java.lang.String getGroupsToken()
ConnectionBase
getGroupsToken
in interface ConnectionBase
public com.google.gson.Gson getGson()
ConnectionBase
getGson
in interface ConnectionBase
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
ConnectionBase
getHeaders
in interface ConnectionBase
public com.google.gson.JsonParser getJsonParser()
ConnectionBase
getJsonParser
in interface ConnectionBase
public Logger getLogger()
ConnectionBase
getLogger
in interface ConnectionBase
public java.lang.String getMessageId()
ConnectionBase
getMessageId
in interface ConnectionBase
public java.lang.String getQueryString()
ConnectionBase
getQueryString
in interface ConnectionBase
public ConnectionState getState()
ConnectionBase
getState
in interface ConnectionBase
public java.lang.String getUrl()
ConnectionBase
getUrl
in interface ConnectionBase
public void onError(java.lang.Throwable error, boolean mustCleanCurrentConnection)
ConnectionBase
onError
in interface ConnectionBase
error
- The error that triggered the eventmustCleanCurrentConnection
- True if the connection must be cleanedpublic void onReceived(com.google.gson.JsonElement message)
onReceived
in interface ConnectionBase
public void prepareRequest(microsoft.aspnet.signalr.client.http.Request request)
ConnectionBase
prepareRequest
in interface ConnectionBase
request
- The request to preparepublic void received(MessageReceivedHandler handler)
ConnectionBase
received
in interface ConnectionBase
public void reconnected(java.lang.Runnable handler)
ConnectionBase
reconnected
in interface ConnectionBase
public void reconnecting(java.lang.Runnable handler)
ConnectionBase
reconnecting
in interface ConnectionBase
public SignalRFuture<java.lang.Void> send(java.lang.Object object)
object
- The object to send. If the object is a JsonElement, its string
representation is sent. Otherwise, the object is serialized to
Json.public SignalRFuture<java.lang.Void> send(java.lang.String data)
ConnectionBase
send
in interface ConnectionBase
data
- Data to sendpublic void setCredentials(Credentials credentials)
ConnectionBase
setCredentials
in interface ConnectionBase
public void setGroupsToken(java.lang.String groupsToken)
ConnectionBase
setGroupsToken
in interface ConnectionBase
public void setMessageId(java.lang.String messageId)
ConnectionBase
setMessageId
in interface ConnectionBase
public SignalRFuture<java.lang.Void> start()
public SignalRFuture<java.lang.Void> start(microsoft.aspnet.signalr.client.transport.ClientTransport transport)
ConnectionBase
start
in interface ConnectionBase
transport
- Transport to be used by the connectionpublic void stateChanged(StateChangedCallback handler)
ConnectionBase
stateChanged
in interface ConnectionBase
public void stop()
ConnectionBase
stop
in interface ConnectionBase