Package connection

Source Code of connection.AbstractContextualConnection

package connection;


import handlers.AbstractContextualHandler;

import java.io.IOException;

import common.connection.AbstractCommunicationSet;
import common.connection.AbstractConnection;
import common.connection.ConnectionWriterAdapter;
import common.connection.ConnectionWriterInterface;


public abstract class AbstractContextualConnection extends AbstractConnection
{
  protected AbstractContextualConnection(AbstractCommunicationSet source)
      throws IOException
  {
    super(source);
  }

  public abstract AbstractContextualHandler getContextualHandler(int protocolId,
      int opcode) throws IOException, ClassNotFoundException;

  protected void processMessage(int protocolId, int opcode) throws IOException,
      ClassNotFoundException
  {
    AbstractContextualHandler handler = getContextualHandler(protocolId, opcode);
    new Thread(handler, handler.getClass().toString()).start();
  }

  public final void sendOverlapped(final int protocolId, final int opcode,
      final ConnectionWriterInterface writer)
  {
    Thread thread = new Thread()
    {
      public void run()
      {
        send(protocolId, opcode, writer);
      }

    };
    thread.start();
  }

  public final void sendOverlapped(int protocolId, int opcode)
  {
    sendOverlapped(protocolId, opcode, new ConnectionWriterAdapter());
  }

}
TOP

Related Classes of connection.AbstractContextualConnection

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.