public class RelayUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static io.netty.buffer.ByteBuf |
composeMessageBuffer(List<Message> messages,
SignatureFactory signatureFactory)
Composes all messages of a list into a single buffer object, ready to be transmitted over the network.
|
static FutureResponse |
connectAndSend(Peer peer,
Message message)
Opens a new peer connection to the receiver and sends the message through it.
|
static Message |
decodeMessage(io.netty.buffer.ByteBuf buf,
InetSocketAddress recipient,
InetSocketAddress sender,
SignatureFactory signatureFactory)
Decodes a message which was encoded using {
encodeMessage(Message, SignatureFactory)}. |
static Message |
decodeRelayedMessage(io.netty.buffer.ByteBuf buf,
InetSocketAddress recipient,
InetSocketAddress sender,
SignatureFactory signatureFactory)
Basically does the same as
MessageUtils#decodeMessage(Buffer, InetSocketAddress, InetSocketAddress, SignatureFactory), but
in addition checks that the relay peers of the decoded message are set correctly |
static String |
decodeString(Buffer buffer)
Decodes buffer containing a String
|
static List<Message> |
decomposeCompositeBuffer(io.netty.buffer.ByteBuf messageBuffer,
InetSocketAddress recipient,
InetSocketAddress sender,
SignatureFactory signatureFactory)
Decomposes a buffer containing multiple buffers into an (ordered) list of small buffers.
|
static Buffer |
encodeMessage(Message message,
SignatureFactory signatureFactory)
Encodes a message into a buffer, such that it can be used as a message payload (piggybacked), stored, etc.
|
static Buffer |
encodeString(String content)
Encodes any String into a buffer to send it with a message
|
static Collection<PeerAddress> |
flatten(List<Map<Number160,PeerStatistic>> maps) |
static int |
getMessageSize(Message message,
SignatureFactory signatureFactory)
Calculates the size of the message
|
static FutureResponse |
send(PeerConnection peerConnection,
PeerBean peerBean,
ConnectionBean connectionBean,
Message message)
Send a Message from one Peer to another Peer internally.
|
static List<Map<Number160,PeerStatistic>> |
unflatten(Collection<PeerAddress> map,
PeerAddress sender) |
public static List<Map<Number160,PeerStatistic>> unflatten(Collection<PeerAddress> map, PeerAddress sender)
public static Collection<PeerAddress> flatten(List<Map<Number160,PeerStatistic>> maps)
public static io.netty.buffer.ByteBuf composeMessageBuffer(List<Message> messages, SignatureFactory signatureFactory)
MessageBuffer#decomposeCompositeBuffer(ByteBuf) to disassemble.messages - the messages to composesignatureFactory - the signature factory, necessary for encoding the messagespublic static List<Message> decomposeCompositeBuffer(io.netty.buffer.ByteBuf messageBuffer, InetSocketAddress recipient, InetSocketAddress sender, SignatureFactory signatureFactory)
messageBuffer - the message bufferpublic static Buffer encodeMessage(Message message, SignatureFactory signatureFactory) throws InvalidKeyException, SignatureException, IOException
public static Message decodeMessage(io.netty.buffer.ByteBuf buf, InetSocketAddress recipient, InetSocketAddress sender, SignatureFactory signatureFactory) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, SignatureException, IOException
encodeMessage(Message, SignatureFactory)}.public static Message decodeRelayedMessage(io.netty.buffer.ByteBuf buf, InetSocketAddress recipient, InetSocketAddress sender, SignatureFactory signatureFactory) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, SignatureException, IOException
MessageUtils#decodeMessage(Buffer, InetSocketAddress, InetSocketAddress, SignatureFactory), but
in addition checks that the relay peers of the decoded message are set correctlypublic static int getMessageSize(Message message, SignatureFactory signatureFactory) throws InvalidKeyException, SignatureException, IOException
public static Buffer encodeString(String content)
content - the String to encode into a bufferpublic static String decodeString(Buffer buffer)
buffer - the buffer received in a messagepublic static FutureResponse send(PeerConnection peerConnection, PeerBean peerBean, ConnectionBean connectionBean, Message message)
public static FutureResponse connectAndSend(Peer peer, Message message)
peer - message - config - Copyright © 2015. All rights reserved.