public interface Connection extends CommunicationLifeCycle
Within the same JFT application several Connections can be created and then opened with the same Server or with several Servers.
TCP/IP
,
charset
used to code/decode the
strings over the line,
Context.makeConnection()
in which the
connection parameters are described by ConnectionParam
and the event
listeners are described by ConnectionListener
.
Once created a connection must be opened (attached to the server), used, and then closed (detached from the server).
Modifier and Type | Field and Description |
---|---|
static int |
STATUS_CONNECTED
Lifecycle status: Connection connected to the
server and ready to be used.
|
static int |
STATUS_CONNECTING
|
static int |
STATUS_DISCONNECTED
|
static int |
STATUS_DISCONNECTING
|
RESULT_GENERIC_ERROR, RESULT_INVALID_STATUS, RESULT_OK, STATUS_INIT, STATUS_RELEASED
Modifier and Type | Method and Description |
---|---|
int |
close()
Try to close this connection with a given server.
|
int |
open()
Try to open this connection with a given server.
|
getContext, getListener, getParam
enumChilds, getStatus, release
static final int STATUS_CONNECTING
open()
server-answer. LifeCycle.getStatus()
.
STATUS_INIT
→ open()
ok →
STATUS_CONNECTING
.
onConnectionOpen()
call.
STATUS_CONNECTING
→
onConnectionOpen()
ok → STATUS_CONNECTED
. STATUS_CONNECTING
→
onConnectionOpen()
bad → STATUS_DISCONNECTED
. STATUS_CONNECTING
→
onConnectionLost()
→ STATUS_DISCONNECTED
.
static final int STATUS_CONNECTED
LifeCycle.getStatus()
.
STATUS_CONNECTING
→
onConnectionOpen()
ok → STATUS_CONNECTED
.
ActivityLifeCycle
objects (with Context
methods
makeSubscription()
,
makeQuery()
,
makeTransanction()
and
makeFilter()
),
TransactionID.belongsTo()
,
ActivityLifeCycle
objects may be used (e.g.
Subscription.start()
, Query.create()
, etc...).
STATUS_CONNECTED
→ close()
ok →
STATUS_DISCONNECTING
. STATUS_CONNECTED
→
onConnectionLost()
→ STATUS_DISCONNECTED
.
static final int STATUS_DISCONNECTING
close()
server-answer. LifeCycle.getStatus()
.
STATUS_CONNECTED
→ close()
ok →
STATUS_DISCONNECTING
.
onConnectionClose()
call.
STATUS_DISCONNECTING
→
onConnectionClose()
→ STATUS_DISCONNECTED
. STATUS_DISCONNECTING
→
onConnectionLost()
→ STATUS_DISCONNECTED
.
static final int STATUS_DISCONNECTED
LifeCycle.getStatus()
.
It's always a good practice to release a Connection in this status.
STATUS_DISCONNECTING
→
onConnectionClose()
→ STATUS_DISCONNECTED
. onConnectionLost()
→ STATUS_DISCONNECTED
.
LifeCycle.release()
.
STATUS_DISCONNECTED
→ LifeCycle.release()
→
STATUS_RELEASED
.
int open()
This method must be called only when
current status is
STATUS_INIT
.
If this method invocation completed successfully,
then
STATUS_CONNECTING
,
ConnectionListener.onConnectionOpen()
will be automatically called to handle it.
otherwise
ConnectionListener.onConnectionOpen()
will not be made,
In the latter case it is a good practice to release this Connection.
RESULT_OK
if the operation completed
successfully,
LifeCycle.RESULT_INVALID_STATUS
if the
current status is not
STATUS_INIT
,
RESULT_GENERIC_ERROR
otherwise int close()
This method must be called only when
current status is STATUS_CONNECTED
.
If this method invocation completed successfully,
then
STATUS_DISCONNECTING
,
ConnectionListener.onConnectionClose()
will be automatically called to handle it.
otherwise
ConnectionListener.onConnectionClose()
will not be made,
It's not a bad practice to unconditionally release this Connection immediately after this method invocation without handling the returned value.
RESULT_OK
if the operation completed
successfully,
LifeCycle.RESULT_INVALID_STATUS
if the
current status is not STATUS_CONNECTED
,
RESULT_GENERIC_ERROR
otherwise.
Submit a bug or feature to FT\API Programming Support