@ServiceHandler(RequestCmd.REMOTE_CONTROL) public void remoteControl(DataInputX din, DataOutputX dout, boolean login) throws IOException { MapPack param = (MapPack) din.readPack(); long session = param.getLong("toSession"); RemoteControl control = new RemoteControl( // param.getText("command"), // System.currentTimeMillis(), // param, param.getLong("fromSession")); boolean result = RemoteControlManager.add(session, control); Logger.println( "[" + RequestCmd.REMOTE_CONTROL + "]" + control.commnad() + " from " + LoginManager.getUser(control.commander()).ip() + " to " + LoginManager.getUser(session).ip() + " " + result); MapPack m = new MapPack(); if (result) { m.put("success", new BooleanValue(true)); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); } else { m.put("success", new BooleanValue(false)); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); } }
public boolean add(String cmd, long session) { if (cmdSet.contains(cmd)) { LoginUser loginUser = LoginManager.getUser(session); if (loginUser != null) { queue.put(new RequestInfo(System.currentTimeMillis(), loginUser.id(), loginUser.ip(), cmd)); return true; } else { queue.put(new RequestInfo(System.currentTimeMillis(), "unknown" + session, "", cmd)); return false; } } return false; }
@ServiceHandler(RequestCmd.REMOTE_CONTROL_ALL) public void remoteControlAll(DataInputX din, DataOutputX dout, boolean login) throws IOException { MapPack param = (MapPack) din.readPack(); RemoteControl control = new RemoteControl( // param.getText("command"), // System.currentTimeMillis(), // param, param.getLong("fromSession")); LoginUser[] users = LoginManager.getLoginUserList(); for (int i = 0, len = (users != null ? users.length : 0); i < len; i++) { long session = users[i].session(); RemoteControlManager.add(session, control); } Logger.println( "[" + RequestCmd.REMOTE_CONTROL_ALL + "]" + control.commnad() + " from " + LoginManager.getUser(control.commander()).ip()); }