FileDocCategorySizeDatePackage
PRUDPPacketReply.javaAPI DocAzureus 3.0.3.42720Wed Nov 29 11:15:30 GMT 2006com.aelitis.net.udp.uc

PRUDPPacketReply

public abstract class PRUDPPacketReply extends PRUDPPacket
author
parg

Fields Summary
public static final int
PR_HEADER_SIZE
private static org.gudy.azureus2.core3.util.AEMonitor
class_mon
private static Map
packet_decoders
Constructors Summary
public PRUDPPacketReply(int _action, int _tran_id)

		super( _action, _tran_id );
	
Methods Summary
public static com.aelitis.net.udp.uc.PRUDPPacketReplydeserialiseReply(PRUDPPacketHandler handler, java.io.DataInputStream is)

		int		action			= is.readInt();
		
		PRUDPPacketReplyDecoder	decoder = (PRUDPPacketReplyDecoder)packet_decoders.get( new Integer( action ));
		
		if ( decoder == null ){
			
			throw( new IOException( "No decoder registered for action '" + action + "'" ));
		}
		
		int		transaction_id	= is.readInt();

		return( decoder.decode( handler, is, action, transaction_id ));
	
public java.lang.StringgetString()

		return( super.getString() + ":reply[trans=" + getTransactionId() + "]" );
	
public static voidregisterDecoders(java.util.Map _decoders)

	
	  
	
				 
	
		try{
			class_mon.enter();
		
			Map	new_decoders = new HashMap( packet_decoders );
			
			Iterator	it = _decoders.keySet().iterator();
			
			while( it.hasNext()){
				
				Integer action = (Integer)it.next();
				
				if ( packet_decoders.containsKey( action )){
					
					Debug.out( "Duplicate codec! " + action );
				}
			}
			
			new_decoders.putAll( _decoders );
			
			packet_decoders	= new_decoders;
			
		}finally{
			
			class_mon.exit();
		}
	
public voidserialise(java.io.DataOutputStream os)

			// add to this and you need to adjust HEADER_SIZE above
		
		os.writeInt( getAction());
		
		os.writeInt( getTransactionId() );