: Class SampleMuxHandler

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

## org.w3c.www.mux
Class SampleMuxHandler

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

public class SampleMuxHandler
extends java.lang.Object
implements MuxStreamHandler

Field Summary
`static int` | `DISCARD` Well known protocols - The echo protocol identifier.
`static int` | `ECHO` Well known protocols - The echo protocol identifier.
`protected java.util.Hashtable` | `protocols` The hashtable of accepted protocols.
`protected static SampleMuxHandler` | `sample` The sigle instance of that class.

Constructor Summary
`SampleMuxHandler()`

Method Summary
`boolean` | `acceptSession(MuxStream stream, int sessid, int protid)` Are we willing to speak the given protocol on the given session.
`static MuxStreamHandler` | `getStreamHandler()` Get an instance of that sample mux stream handler.
`protected void` | `log(java.lang.String msg)` Log an error.
`void` | `notifySession(MuxSession session)` Setup the appropriate protocol handler for that accepted session.
`void` | `registerDefaultHandlers()` Register default protocol handlers for that stream handler.
`void` | `registerHandler(int protid, MuxProtocolHandler handler)` Register an instantiated protocol handler for the given protocol id.
`void` | `registerHandler(int protid, java.lang.String strhandler)` Register a protocol handler for the given protocol identifier.
`void` | `unregisterHandler(int protid)` Unregister any handler for that protocol.

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

Field Detail

### ECHO

    public static final int ECHO

  Well known protocols - The echo protocol identifier.

### DISCARD

    public static final int DISCARD

  Well known protocols - The echo protocol identifier.

### sample

    protected static SampleMuxHandler sample

  The sigle instance of that class.

### protocols

    protected java.util.Hashtable protocols

  The hashtable of accepted protocols.

Constructor Detail

### SampleMuxHandler

    public SampleMuxHandler()

Method Detail

### log

    protected void log(java.lang.String msg)

  Log an error.
  Parameters:
    `msg` - The message to log.

### getStreamHandler

    public static MuxStreamHandler getStreamHandler()

  Get an instance of that sample mux stream handler.
  Returns:
    A MuxStreamHandler conformant instance.

### acceptSession

    public boolean acceptSession(MuxStream stream,
                                 int sessid,
                                 int protid)

  Are we willing to speak the given protocol on the given session.
  Specified by:
    acceptSession in interface MuxStreamHandler
  Parameters:
    `stream` - The stream that received the new session.
    `sessid` - The proposed session identifier.
    `protid` - The protocol to be spoken on that session.
  Returns:
    A bolean, true if the session is accepted, false otherwise.

### notifySession

    public void notifySession(MuxSession session)

  Setup the appropriate protocol handler for that accepted session.
  Specified by:
    notifySession in interface MuxStreamHandler
  Parameters:
    `session` - The newly accepted session.

### registerHandler

    public void registerHandler(int protid,
                                java.lang.String strhandler)

  Register a protocol handler for the given protocol identifier. This method register a class to handle all new connections for the given protocol identifier: each new connection will result in a new instance of the given class being created (the easy, but slow way).
  Parameters:
    `protid` - The protocol identifier.
    `handler` - The name of the class to instantiate in order to get a suitable handler for that protocol.
  See Also:
    `MuxProtocolHandler`

### registerHandler

    public void registerHandler(int protid,
                                MuxProtocolHandler handler)

  Register an instantiated protocol handler for the given protocol id. This other method of registering protocol handler is faster then the previous one: it allows you to spare the instantiation of a protocol handler on each new sessions.

  The given handler will be invoked for all new sessions willing to speak the advertized protocol.

  Parameters:
    `protid` - The protocol identifier.
    `handler` - The instantiated protocol handler.

### unregisterHandler

    public void unregisterHandler(int protid)

  Unregister any handler for that protocol.
  Parameters:
    `protid` - The identifier of the protocol to unregister.

### registerDefaultHandlers

    public void registerDefaultHandlers()

  Register default protocol handlers for that stream handler. This is the right method to override in order to either prevent well known protocols from being registered, or add new protocol handlers.

  Default protocols registered by this class are:

  echo
    The echo protocol.
  discard
    The discard protocol.

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