forked from I2P_Developers/i2p.i2p
* ClientManager: Remove setters, make all fields final
This commit is contained in:
@ -16,60 +16,83 @@ import net.i2p.data.i2cp.SessionConfig;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a message either destined for a local client or received from one.
|
* Wrap a message either destined for a local client or received from one.
|
||||||
|
* Note that an outbound message may get routed as an inbound message
|
||||||
|
* for local-local communication.
|
||||||
*
|
*
|
||||||
* @author jrandom
|
* @author jrandom
|
||||||
*/
|
*/
|
||||||
public class ClientMessage {
|
public class ClientMessage {
|
||||||
private Payload _payload;
|
private final Payload _payload;
|
||||||
private Destination _destination;
|
private final Destination _destination;
|
||||||
private Destination _fromDestination;
|
private final Destination _fromDestination;
|
||||||
//private MessageReceptionInfo _receptionInfo;
|
//private MessageReceptionInfo _receptionInfo;
|
||||||
private SessionConfig _senderConfig;
|
private final SessionConfig _senderConfig;
|
||||||
private Hash _destinationHash;
|
private final Hash _destinationHash;
|
||||||
private MessageId _messageId;
|
private final MessageId _messageId;
|
||||||
private long _expiration;
|
private final long _expiration;
|
||||||
/** only for outbound messages */
|
/** only for outbound messages */
|
||||||
private int _flags;
|
private final int _flags;
|
||||||
|
|
||||||
public ClientMessage() {
|
/**
|
||||||
|
* For outbound (locally originated)
|
||||||
|
* @since 0.9.9
|
||||||
|
*/
|
||||||
|
public ClientMessage(Destination toDest, Payload payload, SessionConfig config, Destination fromDest,
|
||||||
|
MessageId msgID, long expiration, int flags) {
|
||||||
|
_destination = toDest;
|
||||||
|
_destinationHash = null;
|
||||||
|
_payload = payload;
|
||||||
|
_senderConfig = config;
|
||||||
|
_fromDestination = fromDest;
|
||||||
|
_messageId = msgID;
|
||||||
|
_expiration = expiration;
|
||||||
|
_flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For inbound (from remote dest)
|
||||||
|
* @since 0.9.9
|
||||||
|
*/
|
||||||
|
public ClientMessage(Hash toDestHash, Payload payload) {
|
||||||
|
_destination = null;
|
||||||
|
_destinationHash = toDestHash;
|
||||||
|
_payload = payload;
|
||||||
|
_senderConfig = null;
|
||||||
|
_fromDestination = null;
|
||||||
|
_messageId = null;
|
||||||
|
_expiration = 0;
|
||||||
|
_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the payload of the message. All ClientMessage objects should have
|
* Retrieve the payload of the message. All ClientMessage objects should have
|
||||||
* a payload
|
* a payload
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Payload getPayload() { return _payload; }
|
public Payload getPayload() { return _payload; }
|
||||||
public void setPayload(Payload payload) { _payload = payload; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the destination to which this message is directed. All ClientMessage
|
* Retrieve the destination to which this message is directed.
|
||||||
* objects should have a destination.
|
* Valid for outbound; null for inbound.
|
||||||
*
|
* If null, use getDestinationHash()
|
||||||
*/
|
*/
|
||||||
public Destination getDestination() { return _destination; }
|
public Destination getDestination() { return _destination; }
|
||||||
public void setDestination(Destination dest) { _destination = dest; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Valid for outbound; null for inbound.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Destination getFromDestination() { return _fromDestination; }
|
public Destination getFromDestination() { return _fromDestination; }
|
||||||
public void setFromDestination(Destination dest) { _fromDestination = dest; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the destination to which this message is directed. All ClientMessage
|
* Retrieve the destination to which this message is directed.
|
||||||
* objects should have a destination.
|
* Valid for inbound; null for outbound.
|
||||||
*
|
* If null, use getDestination()
|
||||||
*/
|
*/
|
||||||
public Hash getDestinationHash() { return _destinationHash; }
|
public Hash getDestinationHash() { return _destinationHash; }
|
||||||
public void setDestinationHash(Hash dest) { _destinationHash = dest; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Valid for outbound; null for inbound.
|
||||||
*/
|
*/
|
||||||
public MessageId getMessageId() { return _messageId; }
|
public MessageId getMessageId() { return _messageId; }
|
||||||
public void setMessageId(MessageId id) { _messageId = id; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the information regarding how the router received this message. Only
|
* Retrieve the information regarding how the router received this message. Only
|
||||||
@ -83,18 +106,14 @@ public class ClientMessage {
|
|||||||
/**
|
/**
|
||||||
* Retrieve the session config of the client that sent the message. This will only be available
|
* Retrieve the session config of the client that sent the message. This will only be available
|
||||||
* if the client was local
|
* if the client was local
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public SessionConfig getSenderConfig() { return _senderConfig; }
|
public SessionConfig getSenderConfig() { return _senderConfig; }
|
||||||
public void setSenderConfig(SessionConfig config) { _senderConfig = config; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expiration requested by the client that sent the message. This will only be available
|
* Expiration requested by the client that sent the message. This will only be available
|
||||||
* for locally originated messages.
|
* for locally originated messages.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public long getExpiration() { return _expiration; }
|
public long getExpiration() { return _expiration; }
|
||||||
public void setExpiration(long e) { _expiration = e; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags requested by the client that sent the message. This will only be available
|
* Flags requested by the client that sent the message. This will only be available
|
||||||
@ -103,9 +122,4 @@ public class ClientMessage {
|
|||||||
* @since 0.8.4
|
* @since 0.8.4
|
||||||
*/
|
*/
|
||||||
public int getFlags() { return _flags; }
|
public int getFlags() { return _flags; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 0.8.4
|
|
||||||
*/
|
|
||||||
public void setFlags(int f) { _flags = f; }
|
|
||||||
}
|
}
|
||||||
|
@ -244,14 +244,9 @@ class ClientManager {
|
|||||||
// sender went away
|
// sender went away
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClientMessage msg = new ClientMessage();
|
ClientMessage msg = new ClientMessage(toDest, payload, runner.getConfig(),
|
||||||
msg.setDestination(toDest);
|
runner.getConfig().getDestination(), msgId,
|
||||||
msg.setPayload(payload);
|
expiration, flags);
|
||||||
msg.setSenderConfig(runner.getConfig());
|
|
||||||
msg.setFromDestination(runner.getConfig().getDestination());
|
|
||||||
msg.setMessageId(msgId);
|
|
||||||
msg.setExpiration(expiration);
|
|
||||||
msg.setFlags(flags);
|
|
||||||
_ctx.clientMessagePool().add(msg, true);
|
_ctx.clientMessagePool().add(msg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,9 +223,7 @@ class InboundMessageDistributor implements GarlicMessageReceiver.CloveReceiver {
|
|||||||
DataMessage dm = (DataMessage)data;
|
DataMessage dm = (DataMessage)data;
|
||||||
Payload payload = new Payload();
|
Payload payload = new Payload();
|
||||||
payload.setEncryptedData(dm.getData());
|
payload.setEncryptedData(dm.getData());
|
||||||
ClientMessage m = new ClientMessage();
|
ClientMessage m = new ClientMessage(_client, payload);
|
||||||
m.setDestinationHash(_client);
|
|
||||||
m.setPayload(payload);
|
|
||||||
_context.clientManager().messageReceived(m);
|
_context.clientManager().messageReceived(m);
|
||||||
} else {
|
} else {
|
||||||
if (_log.shouldLog(Log.ERROR))
|
if (_log.shouldLog(Log.ERROR))
|
||||||
|
Reference in New Issue
Block a user