Package connection.peer

Source Code of connection.peer.GenericPeerConnection

package connection.peer;


import handlers.AbstractContextualHandler;
import handlers.sets.GenericPeerHandlerSet;

import java.io.IOException;

import transfer.upload.FileUploadConnection;
import chat.connection.AbstractChatConnection;
import chat.connection.ServerSideChatConnection;

import common.connection.AbstractCommunicationSet;
import common.files.SerializableFile;
import common.handlers.AbstractHandlerSet;
import connection.AbstractContextualConnection;


public class GenericPeerConnection extends AbstractContextualConnection
{
  private static final GenericPeerHandlerSet HANDLER_SET = new GenericPeerHandlerSet();

  public GenericPeerConnection(AbstractCommunicationSet source) throws IOException
  {
    super(source);
  }

  public void initializeConnection() throws IOException
  {
  }

  public void finalizeConnection()
  {
  }

  protected AbstractHandlerSet getHandlerSet()
  {
    return HANDLER_SET;
  }

  public AbstractContextualHandler getContextualHandler(int protocolId, int opcode)
      throws IOException, ClassNotFoundException
  {
    return GenericPeerHandlerSet.HANDLERS[protocolId][opcode].createContext(this, is);
  }

  public FileUploadConnection convertToFileUpload(SerializableFile file)
      throws IOException
  {
    FileUploadConnection newConnection = new FileUploadConnection(this, file);
    convertTo(newConnection);
    return newConnection;
  }

  public AbstractChatConnection convertToPrivateChat() throws IOException
  {
    AbstractChatConnection newConnection = new ServerSideChatConnection(this);
    convertTo(newConnection);
    return newConnection;
  }

}
TOP

Related Classes of connection.peer.GenericPeerConnection

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.