| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library shelf_web_socket; | |
| 6 | |
| 7 import 'package:shelf/shelf.dart'; | 5 import 'package:shelf/shelf.dart'; |
| 8 | 6 |
| 9 import 'src/web_socket_handler.dart'; | 7 import 'src/web_socket_handler.dart'; |
| 10 | 8 |
| 11 /// A typedef used to determine if a function takes two arguments or not. | 9 /// A typedef used to determine if a function takes two arguments or not. |
| 12 typedef _BinaryFunction(arg1, arg2); | 10 typedef _BinaryFunction(arg1, arg2); |
| 13 | 11 |
| 14 /// Creates a Shelf handler that upgrades HTTP requests to WebSocket | 12 /// Creates a Shelf handler that upgrades HTTP requests to WebSocket |
| 15 /// connections. | 13 /// connections. |
| 16 /// | 14 /// |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 throw new ArgumentError("If protocols is non-null, onConnection must " | 50 throw new ArgumentError("If protocols is non-null, onConnection must " |
| 53 "take two arguments, the WebSocket and the protocol."); | 51 "take two arguments, the WebSocket and the protocol."); |
| 54 } | 52 } |
| 55 | 53 |
| 56 var innerOnConnection = onConnection; | 54 var innerOnConnection = onConnection; |
| 57 onConnection = (webSocket, _) => innerOnConnection(webSocket); | 55 onConnection = (webSocket, _) => innerOnConnection(webSocket); |
| 58 } | 56 } |
| 59 | 57 |
| 60 return new WebSocketHandler(onConnection, protocols, allowedOrigins).handle; | 58 return new WebSocketHandler(onConnection, protocols, allowedOrigins).handle; |
| 61 } | 59 } |
| OLD | NEW |