Af2NetConnection.close - affluxis/csjava GitHub Wiki
Usage
myConnection.close()
Description
Method; closes the connection with the server and invokes Af2NetConnection.onStatus with a code property of Af2NetConnection.Connect.Closed. For more information, see Af2NetConnection.onStatus. This method disconnects all Af2NetStream objects running over this connection. (To terminate server streams without closing the connection, use Af2NetStream.close.) If you want to reconnect, you must recreate the Af2NetStream object (see “Constructor for the Af2NetStream object”). This method also disconnects all remote shared objects running over this connection. However, you don’t need to recreate the shared object to reconnect. Instead, you can just call Af2SharedObject.connect to re-establish the connection to the shared object.
Example
The following disconnect() function stops the published stream, then calls Af2NetConnection.close to delete the source connection. With no source stream to play, the destination stream automatically ends and is deleted.
private void disconnect() {
// Stops publishing the stream.
srcStream.close();
// Deletes the source stream connection.
connection.close();
}
See also
Af2NetConnection.connect, Af2NetConnection.onStatus, Af2NetStream.close, Af2SharedObject.connect, Af2NetStream.play, Af2NetStream.publish