org.vrspace.server
Class BinarySession

java.lang.Object
  extended byjava.util.Observable
      extended byorg.vrspace.server.Session
          extended byorg.vrspace.server.BinarySession
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
GZipSession

public class BinarySession
extends Session

A session able to send and read raw bytes.

See Also:
BinaryConnection

Nested Class Summary
 
Nested classes inherited from class org.vrspace.server.Session
Session.Status
 
Field Summary
protected  byte[] buffer
           
protected  Filter filter
           
protected  java.io.InputStream in
           
protected  java.io.OutputStream out
           
protected  java.io.OutputStream output
           
protected  long receivedBytes
           
protected  long sentBytes
           
 
Fields inherited from class org.vrspace.server.Session
active, cacheRequests, client, daemon, debugLevel, dispatcher, lastTime, lf, preserveSocket, receivedChars, receivedRequests, relogin, RESPONSE_ERR, RESPONSE_NONE, RESPONSE_OK, sentChars, sentRequests, server, socket, startTime, stopTime, TERMINATOR, writer
 
Constructor Summary
BinarySession()
           
BinarySession(Server server, java.net.Socket s, Dispatcher d, java.io.OutputStream out)
          Creates new Session which will write bytes to out
BinarySession(Server server, java.net.Socket s, Dispatcher d, java.io.OutputStream out, Filter filter)
          Creates new Session which will write bytes to out after filtering them with filter
 
Method Summary
protected  void close()
          End session.
protected  void readln()
          Reads bytes from the socket and writes them to the OutputStream.
protected  void write(byte[] b)
          Send b to the client.
protected  void write(byte[] b, int offset, int len)
          Send subset of b to the client.
 
Methods inherited from class org.vrspace.server.Session
debug, flushRequests, getAddress, getId, getSocket, getStatus, isActive, read, run, sendError, sendRequest, sendResponse, terminate, terminate, write
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer

output

protected java.io.OutputStream output

in

protected java.io.InputStream in

out

protected java.io.OutputStream out

filter

protected Filter filter

sentBytes

protected long sentBytes

receivedBytes

protected long receivedBytes
Constructor Detail

BinarySession

public BinarySession()

BinarySession

public BinarySession(Server server,
                     java.net.Socket s,
                     Dispatcher d,
                     java.io.OutputStream out)
              throws java.lang.Exception
Creates new Session which will write bytes to out


BinarySession

public BinarySession(Server server,
                     java.net.Socket s,
                     Dispatcher d,
                     java.io.OutputStream out,
                     Filter filter)
              throws java.lang.Exception
Creates new Session which will write bytes to out after filtering them with filter

Method Detail

readln

protected void readln()
Reads bytes from the socket and writes them to the OutputStream. If Filter exists, bytes are filtered using Filter.filter( byte[] ) and then written to the OutputStream.

Overrides:
readln in class Session
See Also:
Client

write

protected void write(byte[] b)
              throws java.io.IOException
Send b to the client.

Throws:
java.io.IOException

write

protected void write(byte[] b,
                     int offset,
                     int len)
              throws java.io.IOException
Send subset of b to the client.

Throws:
java.io.IOException

close

protected void close()
End session.

Overrides:
close in class Session