OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 class _SocketBase { | 6 class _SocketBase { |
7 | 7 |
8 /* | 8 /* |
9 * Keep these constants in sync with the native poll event identifiers. | 9 * Keep these constants in sync with the native poll event identifiers. |
10 */ | 10 */ |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (_canActivateHandlers && (_id >= 0)) { | 74 if (_canActivateHandlers && (_id >= 0)) { |
75 EventHandler._sendData(_id, _handler, _handlerMask); | 75 EventHandler._sendData(_id, _handler, _handlerMask); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 void _scheduleEvent(int event) { | 79 void _scheduleEvent(int event) { |
80 _handler.toSendPort().send([1 << event], null); | 80 _handler.toSendPort().send([1 << event], null); |
81 } | 81 } |
82 | 82 |
83 int get port() { | 83 int get port() { |
84 if (_port == null) { | 84 if (_port === null) { |
85 _port = _getPort(); | 85 _port = _getPort(); |
86 } | 86 } |
87 return _port; | 87 return _port; |
88 } | 88 } |
89 | 89 |
90 void close() { | 90 void close() { |
91 if (_id >= 0) { | 91 if (_id >= 0) { |
92 EventHandler._sendData(_id, _handler, 1 << _CLOSE_COMMAND); | 92 EventHandler._sendData(_id, _handler, 1 << _CLOSE_COMMAND); |
93 _handler.close(); | 93 _handler.close(); |
94 _handler = null; | 94 _handler = null; |
95 _id = -1; | 95 _id = -1; |
96 } else { | 96 } else { |
97 // This is to support closing sockets created but never assigned | 97 // This is to support closing sockets created but never assigned |
98 // any actual socket. | 98 // any actual socket. |
99 if (_handler == null) { | 99 if (_handler === null) { |
100 throw new | 100 throw new |
101 SocketIOException("Error: close failed - invalid socket handle"); | 101 SocketIOException("Error: close failed - invalid socket handle"); |
102 } else { | 102 } else { |
103 _handler.close(); | 103 _handler.close(); |
104 _handler = null; | 104 _handler = null; |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 | 109 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 void setDataHandler(void callback()) { | 270 void setDataHandler(void callback()) { |
271 _setHandler(_IN_EVENT, callback); | 271 _setHandler(_IN_EVENT, callback); |
272 } | 272 } |
273 | 273 |
274 void setCloseHandler(void callback()) { | 274 void setCloseHandler(void callback()) { |
275 _setHandler(_CLOSE_EVENT, callback); | 275 _setHandler(_CLOSE_EVENT, callback); |
276 } | 276 } |
277 | 277 |
278 InputStream get inputStream() { | 278 InputStream get inputStream() { |
279 if (_inputStream == null) { | 279 if (_inputStream === null) { |
280 _inputStream = new SocketInputStream(this); | 280 _inputStream = new SocketInputStream(this); |
281 } | 281 } |
282 return _inputStream; | 282 return _inputStream; |
283 } | 283 } |
284 | 284 |
285 OutputStream get outputStream() { | 285 OutputStream get outputStream() { |
286 if (_outputStream == null) { | 286 if (_outputStream === null) { |
287 _outputStream = new SocketOutputStream(this); | 287 _outputStream = new SocketOutputStream(this); |
288 } | 288 } |
289 return _outputStream; | 289 return _outputStream; |
290 } | 290 } |
291 | 291 |
292 SocketInputStream _inputStream; | 292 SocketInputStream _inputStream; |
293 SocketOutputStream _outputStream; | 293 SocketOutputStream _outputStream; |
294 } | 294 } |
295 | 295 |
OLD | NEW |