Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public int getCapacity() {
*
* @param key Unique queue identifier
* @param packet Packet to add to the queue
* @param address The remote socket address
* @return True if adding the packet to the queue succeeded
*/
public boolean queuePacket(long key, ByteBuffer packet, InetSocketAddress address) {
Expand All @@ -75,6 +76,33 @@ public boolean queuePacket(long key, ByteBuffer packet, InetSocketAddress addres
}
}

/**
* Adds one packet to the specified queue that will be sent with the specified socket.
* Will fail if the maximum size of the queue is reached. There is no need to manually create a queue,
* it is automatically created when the first packet is added to it and deleted when it becomes empty.
*
* @param key Unique queue identifier
* @param packet Packet to add to the queue
* @param address The remote socket address
* @param explicitSocket The socket file descriptor to use to send the packet
* @return True if adding the packet to the queue succeeded
*/
public boolean queuePacketWithSocket(long key, ByteBuffer packet, InetSocketAddress address, long explicitSocket) {
synchronized (library) {
if (released) {
return false;
}

int length = packet.remaining();
packetBuffer.clear();
packetBuffer.put(packet);

int port = address.getPort();
String hostAddress = address.getAddress().getHostAddress();
return library.queuePacketWithSocket(instance, key, hostAddress, port, packetBuffer, length, explicitSocket);
}
}

/**
* This is the method that should be called to start processing the queues. It will use the current thread and return
* only when close() method is called on the queue manager.
Expand Down