bt.torrent.messaging.MessageContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bt-core Show documentation
Show all versions of bt-core Show documentation
BitTorrent Client Library (Core)
package bt.torrent.messaging;
import bt.metainfo.TorrentId;
import bt.net.Peer;
import java.util.Optional;
/**
* Provides basic information about the context of a message (both inbound and outbound).
*
* @since 1.0
*/
public class MessageContext {
private Optional torrentId;
private Peer peer;
private ConnectionState connectionState;
MessageContext(Optional torrentId, Peer peer, ConnectionState connectionState) {
this.torrentId = torrentId;
this.peer = peer;
this.connectionState = connectionState;
}
/**
* @return Optional torrent ID or empty if not applicable
* (e.g. if a message was received outside of a torrent processing session)
* @since 1.0
*/
public Optional getTorrentId() {
return torrentId;
}
/**
* @return Remote peer
* @since 1.0
*/
public Peer getPeer() {
return peer;
}
/**
* @return Current state of the connection
* @since 1.0
*/
public ConnectionState getConnectionState() {
return connectionState;
}
}