| java.lang.Object org.w3c.www.mux.SampleMuxHandler
Field Summary | |
final public static int | DISCARD Well known protocols - The echo protocol identifier. | final public static int | ECHO Well known protocols - The echo protocol identifier. | protected Hashtable | protocols The hashtable of accepted protocols. | protected static SampleMuxHandler | sample The sigle instance of that class. |
Method Summary | |
public boolean | acceptSession(MuxStream stream, int sessid, int protid) Are we willing to speak the given protocol on the given session.
Parameters: stream - The stream that received the new session. Parameters: sessid - The proposed session identifier. Parameters: protid - The protocol to be spoken on that session. | public static synchronized MuxStreamHandler | getStreamHandler() Get an instance of that sample mux stream handler. | protected void | log(String msg) Log an error. | public void | notifySession(MuxSession session) Setup the appropriate protocol handler for that accepted session. | public void | registerDefaultHandlers() Register default protocol handlers for that stream handler. | public void | registerHandler(int protid, String strhandler) Register a protocol handler for the given protocol identifier. | public void | registerHandler(int protid, MuxProtocolHandler handler) Register an instantiated protocol handler for the given protocol id. | public void | unregisterHandler(int protid) Unregister any handler for that protocol. |
DISCARD | final public static int DISCARD(Code) | | Well known protocols - The echo protocol identifier.
|
ECHO | final public static int ECHO(Code) | | Well known protocols - The echo protocol identifier.
|
protocols | protected Hashtable protocols(Code) | | The hashtable of accepted protocols.
|
SampleMuxHandler | public SampleMuxHandler()(Code) | | |
acceptSession | public boolean acceptSession(MuxStream stream, int sessid, int protid)(Code) | | Are we willing to speak the given protocol on the given session.
Parameters: stream - The stream that received the new session. Parameters: sessid - The proposed session identifier. Parameters: protid - The protocol to be spoken on that session. A bolean, true if the session is accepted,false otherwise. |
getStreamHandler | public static synchronized MuxStreamHandler getStreamHandler()(Code) | | Get an instance of that sample mux stream handler.
A MuxStreamHandler conformant instance. |
log | protected void log(String msg)(Code) | | Log an error.
Parameters: msg - The message to log. |
notifySession | public void notifySession(MuxSession session)(Code) | | Setup the appropriate protocol handler for that accepted session.
Parameters: session - The newly accepted session. |
registerDefaultHandlers | public void registerDefaultHandlers()(Code) | | 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.
|
registerHandler | public void registerHandler(int protid, String strhandler)(Code) | | 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. Parameters: handler - The name of the class to instantiate in orderto get a suitable handler for that protocol. See Also: MuxProtocolHandler |
registerHandler | public void registerHandler(int protid, MuxProtocolHandler handler)(Code) | | 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. Parameters: handler - The instantiated protocol handler. |
unregisterHandler | public void unregisterHandler(int protid)(Code) | | Unregister any handler for that protocol.
Parameters: protid - The identifier of the protocol to unregister. |
|
|