Methods Summary |
---|
public void | cancelPeerConnection(NetworkConnectionBase connection)Remove a peer connection from the entity handler.
if( handler_type == TransferProcessor.TYPE_UPLOAD ) {
if( !global_uploader.removePeerConnection( connection ) ) { //if not found in the pool entity
SinglePeerUploader upload_entity = (SinglePeerUploader)upgraded_connections.remove( connection ); //check for it in the upgraded list
if( upload_entity != null ) {
NetworkManager.getSingleton().removeWriteEntity( upload_entity ); //cancel from write processing
}
}
}
else {
if( !global_downloader.removePeerConnection( connection ) ) { //if not found in the pool entity
SinglePeerDownloader download_entity = (SinglePeerDownloader)upgraded_connections.remove( connection ); //check for it in the upgraded list
if( download_entity != null ) {
NetworkManager.getSingleton().removeReadEntity( download_entity ); //cancel from read processing
}
}
}
|
public void | downgradePeerConnection(NetworkConnectionBase connection)Downgrade (return) a peer connection back into the general pool.
try { lock.enter();
if( handler_type == TransferProcessor.TYPE_UPLOAD ) {
SinglePeerUploader upload_entity = (SinglePeerUploader)upgraded_connections.remove( connection ); //remove from the upgraded list
if( upload_entity != null ) {
NetworkManager.getSingleton().removeWriteEntity( upload_entity ); //cancel from write processing
}
else {
Debug.out( "upload_entity == null" );
}
global_uploader.addPeerConnection( connection ); //move back to the general pool
}
else {
SinglePeerDownloader download_entity = (SinglePeerDownloader)upgraded_connections.remove( connection ); //remove from the upgraded list
if( download_entity != null ) {
NetworkManager.getSingleton().removeReadEntity( download_entity ); //cancel from read processing
}
else {
Debug.out( "download_entity == null" );
}
global_downloader.addPeerConnection( connection ); //move back to the general pool
}
}
finally { lock.exit(); }
|
public void | registerPeerConnection(NetworkConnectionBase connection)Register a peer connection for management by the handler.
try { lock.enter();
if( !global_registered ) {
if( handler_type == TransferProcessor.TYPE_UPLOAD ) {
NetworkManager.getSingleton().addWriteEntity( global_uploader ); //register global upload entity
}
else {
NetworkManager.getSingleton().addReadEntity( global_downloader ); //register global download entity
}
global_registered = true;
}
}
finally { lock.exit(); }
if( handler_type == TransferProcessor.TYPE_UPLOAD ) {
global_uploader.addPeerConnection( connection );
}
else {
global_downloader.addPeerConnection( connection );
}
|
public void | upgradePeerConnection(NetworkConnectionBase connection, RateHandler handler)Upgrade a peer connection from the general pool to its own high-speed entity.
try { lock.enter();
if( handler_type == TransferProcessor.TYPE_UPLOAD ) {
SinglePeerUploader upload_entity = new SinglePeerUploader( connection, handler );
if( !global_uploader.removePeerConnection( connection ) ) { //remove it from the general upload pool
Debug.out( "upgradePeerConnection:: upload entity not found/removed !" );
}
NetworkManager.getSingleton().addWriteEntity( upload_entity ); //register it for write processing
upgraded_connections.put( connection, upload_entity ); //add it to the upgraded list
}
else {
SinglePeerDownloader download_entity = new SinglePeerDownloader( connection, handler );
if( !global_downloader.removePeerConnection( connection ) ) { //remove it from the general upload pool
Debug.out( "upgradePeerConnection:: download entity not found/removed !" );
}
NetworkManager.getSingleton().addReadEntity( download_entity ); //register it for read processing
upgraded_connections.put( connection, download_entity ); //add it to the upgraded list
}
}
finally { lock.exit(); }
|