annotate rep/REPPacketReceive.java @ 118:bc295d113250

*** empty log message ***
author pin
date Sun, 23 Dec 2007 18:04:00 +0900
parents 628e7ffeb097
children 790c8dd42a7b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
1 package rep;
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
2
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
3 import java.io.IOException;
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
4 import java.nio.ByteBuffer;
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
5 import java.nio.CharBuffer;
27
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
6 import java.nio.channels.SelectionKey;
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
7 import java.nio.channels.SocketChannel;
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
8 import java.nio.charset.CharacterCodingException;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
9 import java.nio.charset.Charset;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
10 import java.nio.charset.CharsetDecoder;
13
00714676d05b *** empty log message ***
pin
parents: 0
diff changeset
11 import java.util.LinkedList;
00714676d05b *** empty log message ***
pin
parents: 0
diff changeset
12 import java.util.StringTokenizer;
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
13
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
14 public class REPPacketReceive {
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
15
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
16 SocketChannel socketchannel;
17
806e34a6fecd *** empty log message ***
pin
parents: 16
diff changeset
17 private final int HEADER_SIZE = 24;
51
e9fba549803e UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 49
diff changeset
18 private final int CHAR_ORDER = 3;
17
806e34a6fecd *** empty log message ***
pin
parents: 16
diff changeset
19 //private String host;
806e34a6fecd *** empty log message ***
pin
parents: 16
diff changeset
20 //private int port;
27
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
21 SelectionKey key;
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
22
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
23 public REPPacketReceive(SocketChannel sc){
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
24 socketchannel = sc;
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
25 }
27
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
26
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
27 public void setkey(SelectionKey key) {
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
28 this.key = key;
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
29 //key.cancel();
2d51078d94dd edit disconnet key.cancel and accept
fuchita
parents: 21
diff changeset
30 }
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
31
49
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
32 public REPCommand unpack() {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
33
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
34 ByteBuffer header = ByteBuffer.allocateDirect(HEADER_SIZE);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
35 long len = 0;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
36 header.clear();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
37 try {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
38 len = socketchannel.read(header);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
39 if(len == -1){
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
40 if(key != null){
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
41 key.cancel();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
42 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
43 socketchannel.close();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
44 return null;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
45 }else if(len == 0){
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
46 return null;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
47 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
48 } catch (IOException e1) {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
49 e1.printStackTrace();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
50 } // limit = read length
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
51 if (len !=HEADER_SIZE) {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
52 System.out.println("てす");
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
53 // this can't happen
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
54 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
55 header.rewind(); // position = 0
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
56
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
57 String text = "";
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
58 int cmd = header.getInt();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
59 int sid = header.getInt();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
60 int eid = header.getInt();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
61 int seqid = header.getInt();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
62 int lineno = header.getInt();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
63 int textsiz = header.getInt()/2;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
64
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
65 ByteBuffer textBuffer = ByteBuffer.allocateDirect(textsiz*2);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
66
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
67 try {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
68 len = socketchannel.read(textBuffer);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
69 } catch (IOException e1) {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
70 e1.printStackTrace();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
71 } // limit = read length
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
72 if (len != textsiz * 2) {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
73 // this can't happen
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
74 System.out.println("あと");
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
75 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
76 textBuffer.rewind();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
77 for(int i=0;i<textsiz;i++) {
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
78 text +=textBuffer.getChar();
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
79 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
80 String string = text;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
81 //System.out.println(string);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
82 //getSocket(string);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
83 REPCommand repcommand = new REPCommand(cmd, sid, eid, seqid, lineno, textsiz, string);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
84 System.out.println("received command: " + repcommand.toString());
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
85 //getSocket(repcommand);
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
86 //System.out.println("received command: " + repcommand.toString());
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
87 return repcommand;
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
88 }
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
89
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
90 public REPCommand unpackUConv() {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
91 ByteBuffer header = ByteBuffer.allocateDirect(HEADER_SIZE);
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
92 long len = 0;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
93 header.clear();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
94 try {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
95 len = socketchannel.read(header);
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
96 if(len == -1){
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
97 if(key != null){
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
98 key.cancel();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
99 }
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
100 socketchannel.close();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
101 return null;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
102 }else if(len == 0){
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
103 return null;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
104 }
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
105 } catch (IOException e1) {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
106 e1.printStackTrace();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
107 } // limit = read length
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
108 if (len !=HEADER_SIZE) {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
109 System.out.println("てす");
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
110 // this can't happen
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
111 }
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
112 header.rewind(); // position = 0
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
113
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
114 int cmd = header.getInt();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
115 int sid = header.getInt();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
116 int eid = header.getInt();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
117 int seqid = header.getInt();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
118 int lineno = header.getInt();
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
119 int textsiz = header.getInt();
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
120 //int tmptextsiz = header.getInt();
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
121 //int textsiz = (tmptextsiz /5) + (tmptextsiz % 5);
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
122
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
123 ByteBuffer textBuffer = ByteBuffer.allocateDirect(textsiz);
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
124
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
125 try {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
126 len = socketchannel.read(textBuffer);
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
127 if(len == -1){
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
128 if(key != null){
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
129 key.cancel();
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
130 }
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
131 socketchannel.close();
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
132 return null;
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
133 }
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
134 } catch (IOException e1) {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
135 e1.printStackTrace();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
136 } // limit = read length
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
137 if (len != textsiz) {
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
138 // this can't happen
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
139 System.out.println("あと");
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
140 }
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
141 textBuffer.rewind();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
142
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
143 //Decode UTF-8 to System Encoding(UTF-16)
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
144 Charset charset = Charset.forName("UTF-8");
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
145 CharsetDecoder decoder = charset.newDecoder();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
146 CharBuffer cb = null;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
147 try {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
148 cb = decoder.decode(textBuffer);
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
149 } catch (CharacterCodingException e) {
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
150 e.printStackTrace();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
151 }
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
152 cb.rewind();
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
153
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
154 String string = cb.toString();
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
155
51
e9fba549803e UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 49
diff changeset
156 textsiz = string.length();
118
bc295d113250 *** empty log message ***
pin
parents: 117
diff changeset
157 // if(textsiz > 2){
bc295d113250 *** empty log message ***
pin
parents: 117
diff changeset
158 // System.out.println(string);
bc295d113250 *** empty log message ***
pin
parents: 117
diff changeset
159 // }
51
e9fba549803e UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 49
diff changeset
160 //System.out.println("CharBuffer size: " +cb.length());
e9fba549803e UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 49
diff changeset
161
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
162 //System.out.println("textsize: " +textsiz);
51
e9fba549803e UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 49
diff changeset
163
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
164 //System.out.println(cb.toString());
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
165
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
166 REPCommand repcommand = new REPCommand(cmd, sid, eid, seqid, lineno, textsiz, string);
46
4fdeeb2d5645 UTF-8 Pack Method PackUConv() add
fuchita
parents: 33
diff changeset
167 System.out.println("UnPack Packet: => cmd:"+cmd+" sid:"+sid+" eid:"+eid+"seqid:"+seqid+" lineno:"+lineno+" textsiz:" +textsiz+" text: "+string);
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
168 System.out.println("received command: " + repcommand.toString());
49
f8b4101746d2 UTF-8 Pack Method packUConv()/unpackUConv() add
fuchita
parents: 46
diff changeset
169
33
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
170 return repcommand;
1b05995d3118 add UTF-8 unpack method -> unpackUConv()
fuchita
parents: 27
diff changeset
171 }
13
00714676d05b *** empty log message ***
pin
parents: 0
diff changeset
172
15
78c211017d3d *** empty log message ***
pin
parents: 14
diff changeset
173 private void getSocket(REPCommand command) {
18
b429fe1e15a8 *** empty log message ***
pin
parents: 17
diff changeset
174 if(command.cmd != REP.SMCMD_JOIN){
15
78c211017d3d *** empty log message ***
pin
parents: 14
diff changeset
175 String string = command.string;
78c211017d3d *** empty log message ***
pin
parents: 14
diff changeset
176 StringTokenizer st2 = new StringTokenizer(string, ":");
20
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
177 LinkedList<String> list = new LinkedList<String>();
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
178 while (st2.hasMoreTokens()){
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
179 list.add(st2.nextToken());
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
180 }
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
181 String port = list.getLast();
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
182 list.removeLast();
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
183 String host = list.getLast();
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
184 int socketInfoLength = host.length() + port.length() + 2;
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
185 System.out.println(host.length() + ":" + port.length() + ":" + socketInfoLength);
15
78c211017d3d *** empty log message ***
pin
parents: 14
diff changeset
186 command.setString(string.substring(0, string.length() - socketInfoLength));
17
806e34a6fecd *** empty log message ***
pin
parents: 16
diff changeset
187 command.setHost(host);
20
83088d943612 *** empty log message ***
pin
parents: 19
diff changeset
188 command.setPort(port);
18
b429fe1e15a8 *** empty log message ***
pin
parents: 17
diff changeset
189 }
13
00714676d05b *** empty log message ***
pin
parents: 0
diff changeset
190 }
0
e41994ce73c7 *** empty log message ***
pin
parents:
diff changeset
191 }