/*
 * Copyright (c) 2016 MCPhoton <http://mcphoton.org> and contributors.
 *
 * This file is part of the Photon Server Implementation <https://github.com/mcphoton/Photon-Server>.
 *
 * The Photon Server Implementation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The Photon Server Implementation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mcphoton.impl.network;

import java.util.Collection;
import java.util.Collections;
import org.mcphoton.network.Packet;

/**
 * Contains informations about a packet to send to some clients.
 *
 * @author TheElectronWill
 */
public final class PacketSending {

	public final Packet packet;
	public final Collection<PhotonClient> clients;

	public PacketSending(Packet packet, PhotonClient client) {
		this.packet = packet;
		this.clients = Collections.singletonList(client);
	}

	public PacketSending(Packet packet, Collection<PhotonClient> clients) {
		this.packet = packet;
		this.clients = clients;
	}

}

@@ -941,47 +941,14 @@
 til.
-Collection;%0Aimport java.util.Collection
+Object
 s;%0Ai
@@ -1042,20 +1042,16 @@
  to 
-some
+a
  client
-s
 .%0A *
@@ -1124,143 +1124,756 @@
 %0A%0A%09p
-ublic final Packet packet;%0A%09public final Collection%3CPhotonClient%3E clients;%0A%0A%09public PacketSending(Packet packet, PhotonClient client) %7B
+rivate static final Runnable NO_ACTION = () -%3E %7B%0A%09%7D;%0A%0A%09/**%0A%09 * The packet to send.%0A%09 */%0A%09public final Packet packet;%0A%0A%09/**%0A%09 * The client to send the packet.%0A%09 */%0A%09public final PhotonClient recipient;%0A%0A%09/**%0A%09 * The action to execute when the sending completes.%0A%09 */%0A%09public final Runnable completionAction;%0A%0A%09/**%0A%09 * Creates a new PacketSending. The completionAction may not be null, use the other constructor to specify%0A%09 * %22no action%22.%0A%09 *%0A%09 * @param packet the packet to send.%0A%09 * @param recipient the client to send the packet.%0A%09 * @param completionAction the action to execute when the sending completes.%0A%09 */%0A%09public PacketSending(Packet packet, PhotonClient recipient, Runnable completionAction) %7B%0A%09%09Objects.requireNonNull(completionAction);
 %0A%09%09t
@@ -1904,56 +1904,215 @@
 his.
-cl
+recip
 ient
-s
  = 
-Collections.singletonList(client);%0A%09%7D%0A
+recipient;%0A%09%09this.completionAction = completionAction;%0A%09%7D%0A%0A%09/**%0A%09 * Creates a new PacketSending.%0A%09 *%0A%09 * @param packet the packet to send.%0A%09 * @param recipient the client to send the packet.%0A%09 */
 %0A%09pu
@@ -2149,19 +2149,8 @@
 et, 
-Collection%3C
 Phot
@@ -2161,17 +2161,18 @@
 ient
-%3E cl
+ recip
 ient
-s
 ) %7B%0A
@@ -2181,50 +2181,207 @@
 this
-.
+(
 packet
- = packet;%0A%09%09this.clients = clients
+, recipient, NO_ACTION);%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return %22PacketSending%7B%22 + %22packet=%22 + packet + %22, recipient=%22 + recipient + %22, completionAction=%22 + completionAction + '%7D'
 ;%0A%09%7D

Make PacketSending simpler, and make it support completionAction.