public interface ConnectionListener
Interface to be implemented in order to handle the Connection Lifecycle.
This interface is bound to connections created by
Context.makeConnection()
.
It may be retrieved by CommunicationLifeCycle.getListener()
.
Method Summary | |
---|---|
void |
onConnectionClose(ConnectionCloseEvent event)
Called when the server-answer to the Connection.close()
is available. |
void |
onConnectionLost(ConnectionLostEvent event)
Called when the connection with server crashed or when the server choose to terminate the connection. |
void |
onConnectionOpen(ConnectionOpenEvent event)
Called when the server-answer to the Connection.open()
is available. |
Method Detail |
---|
void onConnectionOpen(ConnectionOpenEvent event)
Connection.open()
is available.
If the server result is
Event.RESULT_OK
,
then
Connection.STATUS_CONNECTED
.
otherwise
Connection.STATUS_DISCONNECTED
.
In the latter case it is a good practice to
release
the
connection associated to
the event parameter.
event
- the server-answer to the Connection.open()
void onConnectionClose(ConnectionCloseEvent event)
Connection.close()
is available.
If the server result is
Event.RESULT_OK
, then the server has closed the connection
otherwise some unknow error occured.
In both cases:
Connection.STATUS_DISCONNECTED
.
release
the
connection associated to
the event parameter.
It is guaranteed that only one method between
onConnectionClose
and
onConnectionLost
will ever be called on the
same Listener.
event
- the server-answer to the Connection.close()
void onConnectionLost(ConnectionLostEvent event)
In this case:
Event.RESULT_GENERIC_ERROR
.
Connection.STATUS_DISCONNECTED
.
release
the
connection associated to
the event parameter.
It is guaranteed that only one method between
onConnectionClose
and
onConnectionLost
will ever be called on the
same Listener.
event
- the description of this closure