Mercurial > hg > RemoteEditor > REPSessionManager
view test/sematest/TestEditor.java @ 193:311847db7429
*** empty log message ***
author | pin |
---|---|
date | Fri, 29 Aug 2008 20:02:23 +0900 |
parents | |
children | 90965a3bd4f3 |
line wrap: on
line source
package test.sematest; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import rep.REP; import rep.REPCommand; import rep.REPCommandPacker; import rep.channel.REPLogger; import rep.channel.REPSocketChannel; public class TestEditor extends Thread{ private SocketAddress semaIP; private REPLogger ns; public TestEditor(String name, String _host,int _port){ super(name); semaIP = new InetSocketAddress(_host, _port); ns = REPLogger.singleton(); } public void run(){ try { REPSocketChannel<REPCommand> channel; channel = REPSocketChannel.<REPCommand>create(new REPCommandPacker()); 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); REPCommand command = new REPCommand(REP.SMCMD_JOIN,0,0,0,0,0,getName() + ": send hello"); channel.write(command); ns.writeLog("wrote packet", 1); REPCommand packet = channel.read(); ns.writeLog("gets return string==> `"+packet+"\'", 1); ns.writeLog("testEditor exits.", 1); } catch (IOException e) { } } }