OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, the Dart project authors. | 2 * Copyright (c) 2014, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 IContainer getWorkingDir() { | 129 IContainer getWorkingDir() { |
130 return workingDir; | 130 return workingDir; |
131 } | 131 } |
132 | 132 |
133 boolean isAlive() { | 133 boolean isAlive() { |
134 return process != null && !isTerminated() && pubConnection != null | 134 return process != null && !isTerminated() && pubConnection != null |
135 && pubConnection.isConnected(); | 135 && pubConnection.isConnected(); |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
| 139 * Sends an exit on close command to pub, indicating pub serve should shut dow
n when connection is |
| 140 * lost. |
| 141 * |
| 142 * @throws IOException |
| 143 */ |
| 144 void sendExitOnCloseCommand() throws IOException { |
| 145 PubCommands command = pubConnection.getCommands(); |
| 146 command.exitOnClose(); |
| 147 } |
| 148 |
| 149 /** |
139 * Send a urlToAssetId command to the current pub serve | 150 * Send a urlToAssetId command to the current pub serve |
140 * | 151 * |
141 * @param url | 152 * @param url |
142 * @param callback | 153 * @param callback |
143 * @throws IOException | 154 * @throws IOException |
144 */ | 155 */ |
145 void sendGetAssetIdCommand(String url, PubCallback<PubAsset> callback) throws
IOException { | 156 void sendGetAssetIdCommand(String url, PubCallback<PubAsset> callback) throws
IOException { |
146 PubCommands command = pubConnection.getCommands(); | 157 PubCommands command = pubConnection.getCommands(); |
147 command.urlToAssetId(url, callback); | 158 command.urlToAssetId(url, callback); |
148 } | 159 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 pubConnection = new PubConnection(new URI(NLS.bind(WEBSOCKET_URL, LOCAL_HOST
_ADDR, portNumber))); | 231 pubConnection = new PubConnection(new URI(NLS.bind(WEBSOCKET_URL, LOCAL_HOST
_ADDR, portNumber))); |
221 | 232 |
222 pubConnection.addConnectionListener(new PubConnectionListener() { | 233 pubConnection.addConnectionListener(new PubConnectionListener() { |
223 @Override | 234 @Override |
224 public void connectionClosed(PubConnection connection) { | 235 public void connectionClosed(PubConnection connection) { |
225 pubConnection = null; | 236 pubConnection = null; |
226 } | 237 } |
227 }); | 238 }); |
228 | 239 |
229 pubConnection.connect(); | 240 pubConnection.connect(); |
230 | 241 sendExitOnCloseCommand(); |
231 } | 242 } |
232 | 243 |
233 private void copyStream(InputStream in, StringBuilder stringBuilder, boolean t
oConsole) { | 244 private void copyStream(InputStream in, StringBuilder stringBuilder, boolean t
oConsole) { |
234 byte[] buffer = new byte[2048]; | 245 byte[] buffer = new byte[2048]; |
235 try { | 246 try { |
236 int count = in.read(buffer); | 247 int count = in.read(buffer); |
237 while (count != -1) { | 248 while (count != -1) { |
238 if (count > 0) { | 249 if (count > 0) { |
239 String str = new String(buffer, 0, count); | 250 String str = new String(buffer, 0, count); |
240 stringBuilder.append(str); | 251 stringBuilder.append(str); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 315 } |
305 | 316 |
306 if (isTerminated()) { | 317 if (isTerminated()) { |
307 return false; | 318 return false; |
308 } | 319 } |
309 servedDirs.add(directoryToServe); | 320 servedDirs.add(directoryToServe); |
310 | 321 |
311 return true; | 322 return true; |
312 } | 323 } |
313 } | 324 } |
OLD | NEW |