Package chat.connection

Source Code of chat.connection.PrivateChatRequest

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();
  }

}
TOP

Related Classes of chat.connection.PrivateChatRequest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.