Interface NetworkChannel
- All Superinterfaces:
PacketSender
A network channel represents an open connection from/to server.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanactive()Get if the underlying channel is still active and therefore connected.longGet a unique numeric id of this channel.Get the client host from/to the channel is connected.booleanGet if this client is opened by a client rather than a server.voidclose()Requests the close of the channel, flushing all outbound i/o requests before.handler()Get the handler of this channel listening to all kind of operations on this channel.Get the packet listener registry responsible for this channel.Get the query packet manager of this channel.sendQueryAsync(@NonNull Packet packet) Converts and sends the given packet as a query into this channel, returning a future either completed with the response to the query or an exception if no response to the packet was received in time.Get the server host from/to the channel is connected.booleanGet if the underlying channel is currently writeable and will perform writes to the channel immediately.Methods inherited from interface eu.cloudnetservice.driver.network.protocol.PacketSender
sendPacket, sendPacket, sendPacketSync
-
Method Details
-
channelId
long channelId()Get a unique numeric id of this channel. The ids are starting at 1.- Returns:
- a unique numeric id of this channel.
-
serverAddress
Get the server host from/to the channel is connected.- Returns:
- the server address of the channel.
-
clientAddress
Get the client host from/to the channel is connected.- Returns:
- the client address of the channel.
-
handler
Get the handler of this channel listening to all kind of operations on this channel.- Returns:
- the listener for channel operations.
-
packetRegistry
Get the packet listener registry responsible for this channel.- Returns:
- the packet listener registry responsible for this channel.
-
queryPacketManager
Get the query packet manager of this channel.- Returns:
- the query packet manager of this channel.
-
clientProvidedChannel
boolean clientProvidedChannel()Get if this client is opened by a client rather than a server.- Returns:
- true if this channel was opened by a client, false otherwise.
-
sendQueryAsync
Converts and sends the given packet as a query into this channel, returning a future either completed with the response to the query or an exception if no response to the packet was received in time.- Parameters:
packet- the packet to send as a query.- Returns:
- a future completed with the result of the query or an exception in case of a timeout.
- Throws:
NullPointerException- if the given packet is null.
-
writeable
boolean writeable()Get if the underlying channel is currently writeable and will perform writes to the channel immediately.- Returns:
- true if the channel can instantly process i/o requests, false otherwise.
-
active
boolean active()Get if the underlying channel is still active and therefore connected.- Returns:
- true if the channel is connected and active, false otherwise.
-
close
void close()Requests the close of the channel, flushing all outbound i/o requests before. After a channel was closed it cannot be used again.
-