|
Lines 10-18
Link Here
|
| 10 |
******************************************************************************/ |
10 |
******************************************************************************/ |
| 11 |
package org.eclipse.ecf.protocol.msn; |
11 |
package org.eclipse.ecf.protocol.msn; |
| 12 |
|
12 |
|
| 13 |
import java.io.IOException; |
13 |
import java.io.*; |
| 14 |
import java.io.InputStream; |
|
|
| 15 |
import java.io.OutputStream; |
| 16 |
import java.net.Socket; |
14 |
import java.net.Socket; |
| 17 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
| 18 |
|
16 |
|
|
Lines 63-69
Link Here
|
| 63 |
* A thread used to wait indefinitely for incoming messages from the server. |
61 |
* A thread used to wait indefinitely for incoming messages from the server. |
| 64 |
*/ |
62 |
*/ |
| 65 |
private IdleThread idleThread; |
63 |
private IdleThread idleThread; |
| 66 |
|
64 |
|
| 67 |
private boolean closed = false; |
65 |
private boolean closed = false; |
| 68 |
|
66 |
|
| 69 |
Session(MsnClient client) { |
67 |
Session(MsnClient client) { |
|
Lines 117-124
Link Here
|
| 117 |
final void openSocket(String host) throws IOException { |
115 |
final void openSocket(String host) throws IOException { |
| 118 |
closed = false; |
116 |
closed = false; |
| 119 |
int index = host.indexOf(':'); |
117 |
int index = host.indexOf(':'); |
| 120 |
openSocket(host.substring(0, index), Integer.parseInt(host |
118 |
openSocket(host.substring(0, index), Integer.parseInt(host.substring(index + 1))); |
| 121 |
.substring(index + 1))); |
|
|
| 122 |
} |
119 |
} |
| 123 |
|
120 |
|
| 124 |
final void openSocket(String ip, int port) throws IOException { |
121 |
final void openSocket(String ip, int port) throws IOException { |
|
Lines 144-152
Link Here
|
| 144 |
int read = is.read(buffer); |
141 |
int read = is.read(buffer); |
| 145 |
if (read < 1) { |
142 |
if (read < 1) { |
| 146 |
return null; |
143 |
return null; |
| 147 |
} else { |
|
|
| 148 |
return new String(buffer, 0, read).trim(); |
| 149 |
} |
144 |
} |
|
|
145 |
return new String(buffer, 0, read, "UTF-8").trim(); //$NON-NLS-1$ |
| 150 |
} |
146 |
} |
| 151 |
|
147 |
|
| 152 |
/** |
148 |
/** |
|
Lines 164-170
Link Here
|
| 164 |
* channel. |
160 |
* channel. |
| 165 |
*/ |
161 |
*/ |
| 166 |
private final void write(String input, boolean newline) throws IOException { |
162 |
private final void write(String input, boolean newline) throws IOException { |
| 167 |
byte[] bytes = newline ? (input + "\r\n").getBytes() : input.getBytes(); //$NON-NLS-1$ |
163 |
byte[] bytes = newline ? (input + "\r\n").getBytes("UTF-8") : input.getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 168 |
os.write(bytes); |
164 |
os.write(bytes); |
| 169 |
os.flush(); |
165 |
os.flush(); |
| 170 |
} |
166 |
} |
|
Lines 201-208
Link Here
|
| 201 |
* If an I/O error occurs while attempting to write to the |
197 |
* If an I/O error occurs while attempting to write to the |
| 202 |
* channel. |
198 |
* channel. |
| 203 |
*/ |
199 |
*/ |
| 204 |
final void write(String command, String parameters, boolean newline) |
200 |
final void write(String command, String parameters, boolean newline) throws IOException { |
| 205 |
throws IOException { |
|
|
| 206 |
transactionID++; |
201 |
transactionID++; |
| 207 |
write(command + ' ' + transactionID + ' ' + parameters, newline); |
202 |
write(command + ' ' + transactionID + ' ' + parameters, newline); |
| 208 |
} |
203 |
} |
|
Lines 273-279
Link Here
|
| 273 |
idleThread.start(); |
268 |
idleThread.start(); |
| 274 |
} |
269 |
} |
| 275 |
} |
270 |
} |
| 276 |
|
271 |
|
| 277 |
final boolean isClosed() { |
272 |
final boolean isClosed() { |
| 278 |
return closed; |
273 |
return closed; |
| 279 |
} |
274 |
} |