Mercurial > hg > RemoteEditor > REPSessionManager
view rep/handler/REPSessionManagerHandler.java @ 337:5ba5b7a9761b
use REPLogger
author | kono |
---|---|
date | Sun, 12 Oct 2008 18:42:18 +0900 |
parents | dfed28488274 |
children | 86935b872385 |
line wrap: on
line source
package rep.handler; import java.io.IOException; import rep.Forwarder; import rep.REPCommand; import rep.Session; import rep.SessionManager; import rep.channel.REPSelectionKey; import rep.channel.REPSocketChannel; public class REPSessionManagerHandler implements REPHandler { private SessionManager manager; public REPSessionManagerHandler(SessionManager manager) { this.manager = manager; } public void cancel(REPSocketChannel<REPCommand> socketChannel) { manager.remove(socketChannel); } public void handle(REPSelectionKey<REPCommand> key) throws IOException { /* * SessionManagerから来たコマンドは、Editor関係のコマンドは、 * sessionとeidを判定して、そのeditorにforwardしてやれば良い。 * 残りは、manager.manage() で処理する。 */ REPSocketChannel<REPCommand> channel = key.channel1(); REPCommand command = channel.read(); SessionManager.logger.writeLog("REPHandlerImpl.handle() : command = " + command); Session s = manager.getSession(command.sid); Forwarder editor = s.getFirstForwarder(); if (editor!=null) { editor.manage(command); } else { manager.manage(channel, command); } } }