Mercurial > hg > RemoteEditor > REPSessionManager
view test/sematest/Tester.java @ 218:827c439d0da4
*** empty log message ***
author | pin |
---|---|
date | Sun, 31 Aug 2008 07:53:28 +0900 |
parents | |
children | 216d64cd5f3a |
line wrap: on
line source
package test.sematest; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import rep.REPCommand; import rep.REPCommandPacker; import rep.channel.REPLogger; import rep.channel.REPSocketChannel; import test.channeltest.StringPacker; public abstract class Tester extends Thread{ private SocketAddress semaIP; private REPLogger ns; public Tester(String name, String _host,int _port){ super(name); semaIP = new InetSocketAddress(_host, _port); ns = REPLogger.singleton(); ns.setLogLevel(5); } public void run(){ try { REPSocketChannel<REPCommand> channel; channel = REPSocketChannel.<REPCommand>create(new REPCommandPacker()); channel.configureBlocking(true); ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1); while (!channel.connect(semaIP)){ ns.writeLog("SeMa not listen to socket yet, wait", 1); Thread.yield(); } ns.writeLog("successes to connect", 1); sendCommand(channel); ns.writeLog("wrote packet", 1); REPCommand packet = channel.read(); ns.writeLog("gets return string==> `"+packet+"\'", 1); ns.writeLog("testEditor exits.", 1); channel.close1(); } catch (IOException e) {} } public abstract void sendCommand(REPSocketChannel<REPCommand> channel) throws IOException; }