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

PRUDPPacketRequest

public abstract class PRUDPPacketRequest 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
protected long
connection_id
Constructors Summary
public PRUDPPacketRequest(int _action, long _con_id)

		super( _action );
		
		connection_id	= _con_id;
	
protected PRUDPPacketRequest(int _action, long _con_id, int _trans_id)

		super( _action, _trans_id );
		
		connection_id	= _con_id;
	
Methods Summary
public static com.aelitis.net.udp.uc.PRUDPPacketRequestdeserialiseRequest(PRUDPPacketHandler handler, java.io.DataInputStream is)

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

		return( decoder.decode( handler, is, connection_id, action, transaction_id ));
	
public longgetConnectionId()

		return( connection_id );
	
public java.lang.StringgetString()

		return( super.getString() + ":request[con=" + connection_id + ",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.writeLong( connection_id );
		
		os.writeInt( getAction() );
		
		os.writeInt( getTransactionId() );