154
|
1 package test.channeltest;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.net.InetSocketAddress;
|
|
5 import java.net.SocketAddress;
|
|
6
|
|
7 import rep.channel.REPLogger;
|
|
8 import rep.channel.REPSocketChannel;
|
|
9
|
|
10
|
|
11 public class testEditor extends Thread{
|
|
12 private SocketAddress semaIP;
|
|
13 private REPLogger ns;
|
|
14
|
|
15 public testEditor(String name, String _host,int _port){
|
|
16 super(name);
|
|
17 semaIP = new InetSocketAddress(_host, _port);
|
174
|
18 ns = REPLogger.singleton();
|
154
|
19 }
|
|
20
|
|
21 public void run(){
|
|
22 try {
|
|
23 REPSocketChannel<String> channel;
|
187
|
24 channel = REPSocketChannel.<String>create(new StringPacker());
|
209
|
25 channel.configureBlocking(true);
|
154
|
26
|
174
|
27 ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1);
|
154
|
28 while (!channel.connect(semaIP)){
|
174
|
29 ns.writeLog("SeMa not listen to socket yet, wait", 1);
|
154
|
30 Thread.yield();
|
|
31 }
|
174
|
32 ns.writeLog("successes to connect", 1);
|
154
|
33
|
180
|
34 channel.write(getName()+": send hello");
|
174
|
35 ns.writeLog("wrote packet", 1);
|
154
|
36
|
|
37 String packet = channel.read();
|
|
38
|
174
|
39 ns.writeLog("gets return string==> `"+packet+"\'", 1);
|
154
|
40
|
174
|
41 ns.writeLog("testEditor exits.", 1);
|
154
|
42 } catch (IOException e) {
|
|
43 }
|
|
44 }
|
|
45 }
|