Class ErrorMessage
- java.lang.Object
-
- org.drasyl.peer.connection.message.ErrorMessage
-
- All Implemented Interfaces:
Message
,ResponseMessage<RequestMessage>
public class ErrorMessage extends Object
A message representing an error. Such an error should always be handled.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ErrorMessage.Error
Specifies the type of theErrorMessage
.
-
Field Summary
Fields Modifier and Type Field Description protected MessageId
correspondingId
static Supplier<String>
defaultUserAgentGenerator
protected short
hopCount
protected MessageId
id
protected int
networkId
protected ProofOfWork
proofOfWork
protected CompressedPublicKey
recipient
protected CompressedPublicKey
sender
protected String
userAgent
static Supplier<String>
userAgentGenerator
-
Constructor Summary
Constructors Constructor Description ErrorMessage(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, ErrorMessage.Error error, MessageId correspondingId)
Creates a new error message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
MessageId
getCorrespondingId()
ErrorMessage.Error
getError()
short
getHopCount()
Returns this message's hop count.MessageId
getId()
Returns the unique id of this message.int
getNetworkId()
Returns the network the sender belongs to.ProofOfWork
getProofOfWork()
Returns this message sender's proof of work.CompressedPublicKey
getRecipient()
Returns this message's recipient.CompressedPublicKey
getSender()
Returns this message's sender.String
getUserAgent()
Returns the user agent of the sender's node.int
hashCode()
void
incrementHopCount()
Increases the message's hop count.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drasyl.peer.connection.message.Message
getHopCount, getId, getNetworkId, getProofOfWork, getRecipient, getSender, getUserAgent, incrementHopCount
-
-
-
-
Field Detail
-
correspondingId
protected final MessageId correspondingId
-
id
protected final MessageId id
-
userAgent
protected final String userAgent
-
networkId
protected final int networkId
-
sender
protected final CompressedPublicKey sender
-
proofOfWork
protected final ProofOfWork proofOfWork
-
recipient
protected final CompressedPublicKey recipient
-
hopCount
protected short hopCount
-
-
Constructor Detail
-
ErrorMessage
public ErrorMessage(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, ErrorMessage.Error error, MessageId correspondingId)
Creates a new error message.- Parameters:
networkId
- the network the sender belongs tosender
- the message's senderproofOfWork
- sender's proof of workrecipient
- the message's recipienterror
- the error typecorrespondingId
- the corresponding id of the previous message
-
-
Method Detail
-
getError
public ErrorMessage.Error getError()
- Returns:
- the error
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
getCorrespondingId
public MessageId getCorrespondingId()
- Specified by:
getCorrespondingId
in interfaceResponseMessage<R extends RequestMessage>
- Returns:
- the id of the
RequestMessage
to which this response corresponds
-
getId
public MessageId getId()
Description copied from interface:Message
Returns the unique id of this message. Each message generates a random id when it is created.
-
getUserAgent
public String getUserAgent()
Description copied from interface:Message
Returns the user agent of the sender's node.- Specified by:
getUserAgent
in interfaceMessage
- Returns:
- the user agent of the sender's node.
-
getNetworkId
public int getNetworkId()
Description copied from interface:Message
Returns the network the sender belongs to.- Specified by:
getNetworkId
in interfaceMessage
- Returns:
- the network the sender belongs to
-
getSender
public CompressedPublicKey getSender()
Description copied from interface:Message
Returns this message's sender.
-
getProofOfWork
public ProofOfWork getProofOfWork()
Description copied from interface:Message
Returns this message sender's proof of work.- Specified by:
getProofOfWork
in interfaceMessage
- Returns:
- this message sender's proof of work.
-
getRecipient
public CompressedPublicKey getRecipient()
Description copied from interface:Message
Returns this message's recipient.- Specified by:
getRecipient
in interfaceMessage
- Returns:
- this message's recipient.
-
getHopCount
public short getHopCount()
Description copied from interface:Message
Returns this message's hop count. Starts at 0 and is incremented every time it is sent. Once the message reaches the limit defined in configdrasyl.message.hop-limit
it will be dropped.- Specified by:
getHopCount
in interfaceMessage
- Returns:
- this message's hop count.
-
incrementHopCount
public void incrementHopCount()
Description copied from interface:Message
Increases the message's hop count.- Specified by:
incrementHopCount
in interfaceMessage
-
-