OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 patch class ServerSocket { | 5 patch class ServerSocket { |
6 /* patch */ factory ServerSocket(String bindAddress, int port, int backlog) { | 6 /* patch */ factory ServerSocket(String bindAddress, int port, int backlog) { |
7 return new _ServerSocket(bindAddress, port, backlog); | 7 return new _ServerSocket(bindAddress, port, backlog); |
8 } | 8 } |
9 } | 9 } |
10 | 10 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 bool _createConnect(String host, int port) native "Socket_CreateConnect"; | 458 bool _createConnect(String host, int port) native "Socket_CreateConnect"; |
459 | 459 |
460 void set onWrite(void callback()) { | 460 void set onWrite(void callback()) { |
461 if (_outputStream != null) throw new StreamException( | 461 if (_outputStream != null) throw new StreamException( |
462 "Cannot set write handler when output stream is used"); | 462 "Cannot set write handler when output stream is used"); |
463 _clientWriteHandler = callback; | 463 _clientWriteHandler = callback; |
464 _updateOutHandler(); | 464 _updateOutHandler(); |
465 } | 465 } |
466 | 466 |
467 void set onConnect(void callback()) { | 467 void set onConnect(void callback()) { |
468 if (_seenFirstOutEvent || _outputStream != null) { | 468 if (_seenFirstOutEvent) { |
469 throw new StreamException( | 469 throw new StreamException( |
470 "Cannot set connect handler when already connected"); | 470 "Cannot set connect handler when already connected"); |
471 } | 471 } |
472 if (_outputStream != null) { | 472 if (_outputStream != null) { |
473 throw new StreamException( | 473 throw new StreamException( |
474 "Cannot set connect handler when output stream is used"); | 474 "Cannot set connect handler when output stream is used"); |
475 } | 475 } |
476 _clientConnectHandler = callback; | 476 _clientConnectHandler = callback; |
477 _updateOutHandler(); | 477 _updateOutHandler(); |
478 } | 478 } |
(...skipping 23 matching lines...) Expand all Loading... |
502 } | 502 } |
503 _inputStream = new _SocketInputStream(this); | 503 _inputStream = new _SocketInputStream(this); |
504 } | 504 } |
505 return _inputStream; | 505 return _inputStream; |
506 } | 506 } |
507 | 507 |
508 OutputStream get outputStream { | 508 OutputStream get outputStream { |
509 if (_outputStream == null) { | 509 if (_outputStream == null) { |
510 if (_handlerMap[_SocketBase._OUT_EVENT] != null) { | 510 if (_handlerMap[_SocketBase._OUT_EVENT] != null) { |
511 throw new StreamException( | 511 throw new StreamException( |
512 "Cannot get input stream when socket handlers are used"); | 512 "Cannot get output stream when socket handlers are used"); |
513 } | 513 } |
514 _outputStream = new _SocketOutputStream(this); | 514 _outputStream = new _SocketOutputStream(this); |
515 } | 515 } |
516 return _outputStream; | 516 return _outputStream; |
517 } | 517 } |
518 | 518 |
519 void set _onWrite(void callback()) { | 519 void set _onWrite(void callback()) { |
520 _setHandler(_SocketBase._OUT_EVENT, callback); | 520 _setHandler(_SocketBase._OUT_EVENT, callback); |
521 } | 521 } |
522 | 522 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 bool _seenFirstOutEvent = false; | 598 bool _seenFirstOutEvent = false; |
599 bool _pipe = false; | 599 bool _pipe = false; |
600 Function _clientConnectHandler; | 600 Function _clientConnectHandler; |
601 Function _clientWriteHandler; | 601 Function _clientWriteHandler; |
602 _SocketInputStream _inputStream; | 602 _SocketInputStream _inputStream; |
603 _SocketOutputStream _outputStream; | 603 _SocketOutputStream _outputStream; |
604 String _remoteHost; | 604 String _remoteHost; |
605 int _remotePort; | 605 int _remotePort; |
606 static SendPort _socketService; | 606 static SendPort _socketService; |
607 } | 607 } |
OLD | NEW |