package fr.insa.clavardator.client.users;

import fr.insa.clavardator.lib.network.TcpConnection;
import fr.insa.clavardator.lib.util.ErrorCallback;
import fr.insa.clavardator.lib.util.SimpleCallback;
import org.jetbrains.annotations.Nullable;

import java.io.Serializable;

public abstract class PeerConnection {
	public abstract void send(Serializable message, @Nullable SimpleCallback callback, @Nullable ErrorCallback errorCallback);

	/**
	 * Subscribe to this user messages.
	 * If receiving new user info, update this user.
	 * If receiving text message, store it in the history.
	 *
	 * @param errorCallback Callback on error
	 */
	public abstract void receive(TcpConnection.MessageReceivedCallback callback, ErrorCallback errorCallback);

	/**
	 * Close the connection and set state to disconnected
	 */
	public abstract void disconnect();


}
