net.sf.jbaobab.io
Class SimpleSocketCore<P>

java.lang.Object
  extended by net.sf.jbaobab.io.SimpleSocketCore<P>
All Implemented Interfaces:
ChannelCore<P>, SocketCore<P>
Direct Known Subclasses:
ThreadedSocketCore

public class SimpleSocketCore<P>
extends Object
implements SocketCore<P>

A SocketCore that shares same thread with ChannelManager.

Author:
Oakyoon Cha

Field Summary
protected  GrowingByteBuffer buffer
           
protected  SocketChannel channel
           
protected static boolean DEBUG
           
protected static ByteBuffer EOF
           
protected  Protocol<P> protocol
           
protected  Queue<ByteBuffer> queue
           
protected  ChannelManager<SocketChannel> receiver
           
protected  ChannelManager<SocketChannel> sender
           
 
Constructor Summary
SimpleSocketCore(Protocol<P> protocol)
           
 
Method Summary
 SocketChannel channel()
           
 void prepare(SocketChannel channel, ChannelManager<SocketChannel> receiver, ChannelManager<SocketChannel> sender)
           
 Protocol<P> protocol()
           
 int receive(PacketHandler<P> handler)
           
 void schedulePacket(P packet)
           
 void scheduleShutdown()
           
 int send()
           
 void shutdown()
           
 String toString()
           
 String track()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG

EOF

protected static ByteBuffer EOF

protocol

protected Protocol<P> protocol

buffer

protected GrowingByteBuffer buffer

queue

protected Queue<ByteBuffer> queue

channel

protected SocketChannel channel

receiver

protected ChannelManager<SocketChannel> receiver

sender

protected ChannelManager<SocketChannel> sender
Constructor Detail

SimpleSocketCore

public SimpleSocketCore(Protocol<P> protocol)
Method Detail

prepare

public void prepare(SocketChannel channel,
                    ChannelManager<SocketChannel> receiver,
                    ChannelManager<SocketChannel> sender)
Specified by:
prepare in interface SocketCore<P>

channel

public SocketChannel channel()
Specified by:
channel in interface SocketCore<P>

protocol

public Protocol<P> protocol()
Specified by:
protocol in interface ChannelCore<P>

receive

public int receive(PacketHandler<P> handler)
            throws IOException
Specified by:
receive in interface ChannelCore<P>
Throws:
IOException

send

public int send()
         throws IOException
Specified by:
send in interface ChannelCore<P>
Throws:
IOException

shutdown

public void shutdown()
Specified by:
shutdown in interface ChannelCore<P>

schedulePacket

public void schedulePacket(P packet)
Specified by:
schedulePacket in interface ChannelCore<P>

scheduleShutdown

public void scheduleShutdown()
Specified by:
scheduleShutdown in interface ChannelCore<P>

track

public String track()
Specified by:
track in interface ChannelCore<P>

toString

public String toString()
Overrides:
toString in class Object