comparison test/sematest/TestEditor.java @ 193:311847db7429

*** empty log message ***
author pin
date Fri, 29 Aug 2008 20:02:23 +0900
parents
children 90965a3bd4f3
comparison
equal deleted inserted replaced
192:6fb97c7a0b42 193:311847db7429
1 package test.sematest;
2
3 import java.io.IOException;
4 import java.net.InetSocketAddress;
5 import java.net.SocketAddress;
6
7 import rep.REP;
8 import rep.REPCommand;
9 import rep.REPCommandPacker;
10 import rep.channel.REPLogger;
11 import rep.channel.REPSocketChannel;
12
13
14 public class TestEditor extends Thread{
15 private SocketAddress semaIP;
16 private REPLogger ns;
17
18 public TestEditor(String name, String _host,int _port){
19 super(name);
20 semaIP = new InetSocketAddress(_host, _port);
21 ns = REPLogger.singleton();
22 }
23
24 public void run(){
25 try {
26 REPSocketChannel<REPCommand> channel;
27 channel = REPSocketChannel.<REPCommand>create(new REPCommandPacker());
28
29 ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1);
30 while (!channel.connect(semaIP)){
31 ns.writeLog("SeMa not listen to socket yet, wait", 1);
32 Thread.yield();
33 }
34 ns.writeLog("successes to connect", 1);
35
36 REPCommand command = new REPCommand(REP.SMCMD_JOIN,0,0,0,0,0,getName() + ": send hello");
37 channel.write(command);
38 ns.writeLog("wrote packet", 1);
39
40 REPCommand packet = channel.read();
41
42 ns.writeLog("gets return string==> `"+packet+"\'", 1);
43
44 ns.writeLog("testEditor exits.", 1);
45 } catch (IOException e) {
46 }
47 }
48 }