package chat.connection;
import java.io.IOException;
import java.net.InetSocketAddress;
import static main.ClientMain.*;
import ui.misc.MessageBox;
import common.connection.AbstractCommunicationSet;
import common.connection.client.AbstractClientSideConnector;
import common.connection.client.ConnectionAttempt;
import common.connection.client.ConnectionAttempterInterface;
import connection.peer.GenericPeerConnection;
import connection.peer.secure.AbstractSecuredConnectorToPeer;
public class PrivateChatRequest extends AbstractSecuredConnectorToPeer implements
ConnectionAttempterInterface
{
public PrivateChatRequest(GenericPeerConnection source)
{
super();
getStatusManager().setStatusMessage(this, "starting chat session...");
new ConnectionAttempt(this, new InetSocketAddress(source.getAddress(), source
.getPort()));
}
public AbstractClientSideConnector getConnector()
{
return this;
}
public void notifyFailure()
{
resetStatus();
MessageBox.showInformation(
"Unable to start a private chat session with the specified user.",
"Connection error");
}
public void notifySuccess()
{
resetStatus();
}
private void resetStatus()
{
getStatusManager().resetStatusMessage(this);
}
public GenericPeerConnection createConnection(AbstractCommunicationSet source)
throws IOException
{
return new ClientSideChatConnection(source, this);
}
public void notifyFailedNegotiation()
{
notifyFailure();
}
}