Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.www.mux
Class MuxStream

    java.lang.Object
      |
      +--org.w3c.www.mux.MuxStream

public class MuxStream
extends java.lang.Object

Field Summary
`protected boolean` | `alive` Is this muxed stream still alive ?
`protected MuxStreamHandler` | `handler` That stream accept handler.
`protected java.io.InputStream` | `in` The raw input stream.
`protected java.net.InetAddress` | `inetaddr` Inet address of the other end's connection (maybe null)
`protected java.io.OutputStream` | `out` The raw output stream.
`protected org.w3c.www.mux.MuxReader` | `reader` This stream reader.
`protected boolean` | `server` Is this the server side of the MUX channel ?
`protected MuxSession[]` | `sessions` Currently defined sessions.
`protected org.w3c.www.mux.MuxWriter` | `writer` This stream writer.

Constructor Summary
`MuxStream(boolean server, MuxStreamHandler handler, java.io.InputStream in, java.io.OutputStream out)`
`MuxStream(boolean server, MuxStreamHandler handler, java.net.Socket socket)`

Method Summary
`MuxSession` | `connect(int protid)` Create a new MUX session, by connecting to the other end.
`protected void` | `ctrlDefineStack(int id, int[] stack)` Handle the given DefineStack control message.
`protected void` | `ctrlDefineString(int strid, java.lang.String str)` Handle the given DefineString control message.
`protected void` | `ctrlMuxControl(int sessid, int fragsz)` Handle the given MuxControl control message.
`protected void` | `ctrlSendCredit(int sessid, int credit)` Handle the given SendCredit control message.
`protected void` | `error(java.lang.Object obj, java.lang.Exception ex)` A severe (fatal for that connection) errror has occured.
`protected void` | `error(java.lang.Object obj, java.lang.String msg)` A soft error has occured (eg socket close), Cleanup.
`java.net.InetAddress` | `getInetAddress()` Get the InetAddress associated with that MUX stream, if any.
`protected org.w3c.www.mux.MuxWriter` | `getMuxWriter()` Get this stream MuxWriter object.
`protected MuxSession` | `lookupSession(int sessid, boolean check)` Lookup for an already existing session having the given identifier.
`protected MuxSession` | `lookupSession(int flags, int sessid, int length, int llength)` Handle that new incomming message.
`boolean` | `shutdown(boolean force)` Shutdown this stream, and associated sessions gracefully.
`protected void` | `unregisterSession(MuxSession session)` Unregiter the given session, it has been closed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### handler

    protected MuxStreamHandler handler

  That stream accept handler.

### reader

    protected org.w3c.www.mux.MuxReader reader

  This stream reader.

### writer

    protected org.w3c.www.mux.MuxWriter writer

  This stream writer.

### sessions

    protected MuxSession[] sessions

  Currently defined sessions.

### server

    protected boolean server

  Is this the server side of the MUX channel ?

### inetaddr

    protected java.net.InetAddress inetaddr

  Inet address of the other end's connection (maybe null)

### in

    protected java.io.InputStream in

  The raw input stream.

### out

    protected java.io.OutputStream out

  The raw output stream.

### alive

    protected boolean alive

  Is this muxed stream still alive ?

Constructor Detail

### MuxStream

    public MuxStream(boolean server,
                     MuxStreamHandler handler,
                     java.io.InputStream in,
                     java.io.OutputStream out)
              throws java.io.IOException

### MuxStream

    public MuxStream(boolean server,
                     MuxStreamHandler handler,
                     java.net.Socket socket)
              throws java.io.IOException

Method Detail

### getMuxWriter

    protected final org.w3c.www.mux.MuxWriter getMuxWriter()

  Get this stream MuxWriter object.

  Returns:
    A MuxWriter instance.

### error

    protected void error(java.lang.Object obj,
                         java.lang.Exception ex)

  A severe (fatal for that connection) errror has occured. Cleanup.

  Parameters:
    `obj` - The object that has generated the error.
    `ex` - The exception that triggered the error (or null null if this was a logical error).

### error

    protected void error(java.lang.Object obj,
                         java.lang.String msg)

  A soft error has occured (eg socket close), Cleanup.

  Parameters:
    `obj` - The object that has detected the soft error.
    `msg` - An associated String message.

### ctrlDefineString

    protected void ctrlDefineString(int strid,
                                    java.lang.String str)

  Handle the given DefineString control message.

  Parameters:
    `strid` - The identifier for that String in the futur.
    `str` - This String being defined.

### ctrlDefineStack

    protected void ctrlDefineStack(int id,
                                   int[] stack)
                            throws java.io.IOException

  Handle the given DefineStack control message.

  Parameters:
    `id` - The identifier for that stack in the future.
    `stack` - The stack description (as an array of shorts).
    `java.io.IOException`

### ctrlMuxControl

    protected void ctrlMuxControl(int sessid,
                                  int fragsz)
                           throws java.io.IOException

  Handle the given MuxControl control message.

  Parameters:
    `sessid` - The session to which that message applies.
    `fragsz` - The max allowed fragment size on that session.
    `java.io.IOException`

### ctrlSendCredit

    protected void ctrlSendCredit(int sessid,
                                  int credit)
                           throws java.io.IOException

  Handle the given SendCredit control message.

  Parameters:
    `sessid` - The session to which that message applies.
    `credit` - The allowed credits.
    `java.io.IOException`

### lookupSession

    protected MuxSession lookupSession(int flags,
                                       int sessid,
                                       int length,
                                       int llength)
                                throws java.io.IOException

  Handle that new incomming message. This method is called by the reader of that session, to dispatch the message currently being read.

  Returns:
    A MuxSession instance to dispatch that message to, or null otherwise (ie a new session was rejected, etc). In that last case, it is up to the reader of that session to discard any pending data.
    `java.io.IOException`

### lookupSession

    protected MuxSession lookupSession(int sessid,
                                       boolean check)

  Lookup for an already existing session having the given identifier.

  Parameters:
    `sessid` - The identifier of the session to look for.
    `check` - Is null a valid answer, if set and the requested session doesn't exist, a runtime exception is thrown.
  Returns:
    A MuxSession instance, or null if check is false and no session was found.

### unregisterSession

    protected void unregisterSession(MuxSession session)

  Unregiter the given session, it has been closed.

  Parameters:
    `session` - The session to unregister.

### connect

    public MuxSession connect(int protid)
                       throws java.io.IOException

  Create a new MUX session, by connecting to the other end.

  Parameters:
    `protid` - The protocol that is going to be spoken on that new session.
  Returns:
    A connected MuxSession.
  Throws:
    `java.io.IOException` - If the connection couldn't be set up properly.

### getInetAddress

    public java.net.InetAddress getInetAddress()

  Get the InetAddress associated with that MUX stream, if any. MUX streams can run on any kind of Input/Output streams. This method will only return a non-null instance when possible.

  Returns:
    An InetAddress instance, or null if not available.

### shutdown

    public boolean shutdown(boolean force)
                     throws java.io.IOException

  Shutdown this stream, and associated sessions gracefully.

  Parameters:
    `force` - If true abort all existing sessions, and close the muxed streams physically. Otherwise, shutdown the muxed stream gracefully only if no more sessions are running.
  Returns:
    A boolean, true if shutdown was performed, false if it was not performed because force was false and some sessions were still running.
  Throws:
    `java.io.IOException` - If some IO error occured.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD