public DataOutputX wrttenDecimal(long v) throws IOException { this.writeDecimal(v); this.flush(); return this; }
public DataOutputX wrttenDecimal(long v) throws IOException { this.writeDecimal(v); this.flush(); return this; }
public DataOutputX wrttenDecimal(long v) throws IOException { this.writeDecimal(v); this.flush(); return this; }
public DataOutputX wrttenDecimal(long v) throws IOException { this.writeDecimal(v); this.flush(); return this; }
public DataOutputX wrttenDecimal(long v) throws IOException { this.writeDecimal(v); this.flush(); return this; }
out.writeInt(NetCafe.TCP_AGENT_REQ); out.writeInt(objHash); out.flush(); return true; } catch (Exception e) {
public synchronized void sendClose() { if (tcp.connected() == false) { return; } DataOutputX out = tcp.getOutput(); try { out.writeText(RequestCmd.CLOSE); out.flush(); } catch (Exception e) { } }
public void open(int serverId) { close(); Server server = ServerManager.getInstance().getServer(serverId); if (server == null) { return; } try { socket = new Socket(); socket.setKeepAlive(false); socket.setTcpNoDelay(true); socket.setPerformancePreferences(0, 2, 1); socket.setReuseAddress(true); socket.setSoLinger(true, 1000); socket.connect(new InetSocketAddress(server.getIp(), server.getPort()),3000); socket.setSoTimeout(server.getSoTimeOut()); in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); out.writeInt(NetCafe.TCP_CLIENT); out.flush(); log.info("Connected {} to {}:{}", this, server.getIp(), server.getPort()); } catch (Throwable t) { log.error(t.getMessage()); close(); } }
private void process(Socket socket) throws IOException { DataInputX in = null; DataOutputX out = null; try { in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); out.writeInt(NetCafe.TCP_AGENT); out.writeInt(objHash); out.flush(); while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); if (res != null) { out.writeByte(TcpFlag.HasNEXT); out.writePack(res); } out.writeByte(TcpFlag.NoNEXT); out.flush(); } } finally { FileUtil.close(in); FileUtil.close(out); } }
private void process(Socket socket) throws IOException { DataInputX in = null; DataOutputX out = null; try { in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); out.writeInt(NetCafe.TCP_AGENT); out.writeInt(objHash); out.flush(); while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); if (res != null) { out.writeByte(TcpFlag.HasNEXT); out.writePack(res); } out.writeByte(TcpFlag.NoNEXT); out.flush(); } } finally { FileUtil.close(in); FileUtil.close(out); } }
private void process(Socket socket) throws IOException { DataInputX in = null; DataOutputX out = null; try { in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); out.writeInt(NetCafe.TCP_AGENT); out.writeInt(objHash); out.flush(); while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); if (res != null) { out.writeByte(TcpFlag.HasNEXT); out.writePack(res); } out.writeByte(TcpFlag.NoNEXT); out.flush(); } } finally { FileUtil.close(in); FileUtil.close(out); } }
private void process(Socket socket) throws IOException { DataInputX in = null; DataOutputX out = null; try { in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); out.writeInt(NetCafe.TCP_AGENT); out.writeInt(objHash); out.flush(); while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); if (res != null) { out.writeByte(TcpFlag.HasNEXT); out.writePack(res); } out.writeByte(TcpFlag.NoNEXT); out.flush(); } } finally { FileUtil.close(in); FileUtil.close(out); } }
@ServiceHandler(RequestCmd.SERVER_DB_LIST) public void listDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException { String rootPath = DBCtr.getRootPath(); MapPack m = new MapPack(); ListValue nameLv = m.newList("name"); ListValue sizeLv = m.newList("size"); ListValue lastModifiedLv = m.newList("lastModified"); File dbDir = new File(rootPath); long totalLength = 0; if (dbDir.exists() && dbDir.isDirectory()) { totalLength = collectDirectory(dbDir, nameLv, sizeLv, lastModifiedLv, dbDir.getAbsolutePath()); } if (SystemUtil.IS_JAVA_1_5 == false) { m.put("free", dbDir.getUsableSpace()); } m.put("total", totalLength); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); dout.flush(); } @ServiceHandler(RequestCmd.SERVER_DB_DELETE)
@ServiceHandler(RequestCmd.SERVER_DB_DELETE) public void deleteDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException { String rootPath = DBCtr.getRootPath(); MapPack param = (MapPack) din.readPack(); ListValue fileLv = param.getList("file"); MapPack m = new MapPack(); if (fileLv != null) { for (int i = 0; i < fileLv.size(); i++) { String filename = fileLv.getString(i); File file = new File(rootPath + filename); deleteFiles(file); } m.put("size", fileLv.size()); } dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); dout.flush(); } @ServiceHandler(RequestCmd.REMOTE_CONTROL)
public static MapPack loginByCleanConnection(int serverId, MapPack param) throws IOException { TcpProxy proxy = new TcpProxy(serverId); proxy.open(); if (proxy.isValid() == false) { return null; } param.put("ip", proxy.getLocalInetAddress().getHostAddress()); DataOutputX out = proxy.getClientTcp().getOutput(); DataInputX in = proxy.getClientTcp().getInput(); try { out.writeText(RequestCmd.LOGIN); out.writeLong(0); out.writePack(param); out.flush(); MapPack pack = null; while (in.readByte() == TcpFlag.HasNEXT) { pack = (MapPack) in.readPack(); } return pack; } finally { proxy.realClose(); } }
out.writePack((Pack) param); out.flush(); byte resFlag; while ((resFlag = in.readByte()) == TcpFlag.HasNEXT) {