- All Known Implementing Classes:
InboundEstablishState, NTCPConnection.NTCP2ReadState
- Enclosing class:
NTCP2Payload
public static interface NTCP2Payload.PayloadCallback
For all callbacks, recommend throwing exceptions only from the handshake. Exceptions will get thrown out of
NTCP2Payload.processPayload(I2PAppContext, NTCP2Payload.PayloadCallback, byte[], int, int, boolean) and prevent processing of succeeding blocks.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidgotDateTime(long time) Receive the data/time block.voidgotI2NP(I2NPMessage msg) Receive an I2NP message block.voidgotOptions(byte[] options, boolean isHandshake) Receive an options block, the peer's padding negotiation parameters.voidgotPadding(int paddingLength, int frameLength) For stats.voidgotRI(RouterInfo ri, boolean isHandshake, boolean flood) Receive a RouterInfo block.voidgotTermination(int reason, long lastReceived) Receive a termination block, the peer is closing the connection.voidgotUnknown(int type, int len) Receive an unknown block type.
Method Details
gotDateTime
Receive the data/time block.- Parameters:
time- milliseconds since the epoch, as sent in the block- Throws:
DataFormatException- if the callback cannot process the block
gotI2NP
Receive an I2NP message block.- Parameters:
msg- the message, already deserialized out of the frame- Throws:
I2NPMessageException- if the callback cannot process the message
gotOptions
Receive an options block, the peer's padding negotiation parameters.- Parameters:
options- the option bytes, copied out of the frameisHandshake- true only for message 3 part 2- Throws:
DataFormatException- if the callback cannot process the block
gotRI
Receive a RouterInfo block.- Parameters:
ri- will already be validatedisHandshake- true only for message 3 part 2flood- true if the flag byte asks the receiver to flood this RouterInfo- Throws:
DataFormatException- if the RouterInfo is rejected, e.g. an unpublished date
gotTermination
void gotTermination(int reason, long lastReceived) Receive a termination block, the peer is closing the connection.- Parameters:
reason- the termination reason codelastReceived- in theory could wrap around to negative, but very unlikely
gotPadding
void gotPadding(int paddingLength, int frameLength) For stats.- Parameters:
paddingLength- the number of padding bytes, not including the 3-byte block headerframeLength- the total size of the frame, including all blocks and block headers
gotUnknown
void gotUnknown(int type, int len) Receive an unknown block type.- Parameters:
type- the block type byte from the block headerlen- the block length in bytes, not counting the 3-byte header