Updated websocket

This commit is contained in:
Thomas Hii 2024-06-03 11:28:23 +08:00
parent 9ba0092b4f
commit e802de14f1
17 changed files with 51 additions and 24 deletions

View file

@ -1,5 +1,10 @@
# Change Log # Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1 ## 8.1.1
* Updated repository link * Updated repository link

View file

@ -1,6 +1,6 @@
name: angel3_auth name: angel3_auth
description: A complete authentication plugin for Angel3. Includes support for stateless JWT tokens, Basic Auth, and more. description: A complete authentication plugin for Angel3. Includes support for stateless JWT tokens, Basic Auth, and more.
version: 8.1.1 version: 8.2.0
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth repository: https://github.com/dart-backend/angel/tree/master/packages/auth
environment: environment:

View file

@ -1,5 +1,10 @@
# Change Log # Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1 ## 8.1.1
* Updated repository link * Updated repository link

View file

@ -1,5 +1,5 @@
name: angel3_auth_oauth2 name: angel3_auth_oauth2
version: 8.1.1 version: 8.2.0
description: Angel3 library for authenticating users with external identity providers via OAuth2. description: Angel3 library for authenticating users with external identity providers via OAuth2.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_oauth2 repository: https://github.com/dart-backend/angel/tree/master/packages/auth_oauth2

View file

@ -2,11 +2,11 @@
## 8.0.0 ## 8.0.0
* Require Dart >= 3.0 * Require Dart >= 3.3
* Updated `oauth1` to `belatuk_oauth1` * Updated `oauth1` to `belatuk_oauth1`
* Updated `lints` to 3.0.0 * Updated `lints` to 4.0.0
* Fixed linter warnings
* Updated repository link * Updated repository link
* Fixed linter warnings
## 7.0.0 ## 7.0.0

View file

@ -5,6 +5,7 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth_twitter/LICENSE) [![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth_twitter/LICENSE)
**Not ready for release**
Angel3 authentication strategy using Twitter OAuth 1.0a. Angel3 authentication strategy using Twitter OAuth 1.0a.
See the [example](example/example.dart); See the [example](example/example.dart);

View file

@ -1,11 +1,11 @@
name: "angel3_auth_twitter" name: "angel3_auth_twitter"
description: Angel3 authentication strategy for Twitter login. Auto-signs requests. description: Angel3 authentication strategy for Twitter login. Auto-signs requests.
version: 8.0.1 version: 8.0.0
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_twitter repository: https://github.com/dart-backend/angel/tree/master/packages/auth_twitter
publish_to: none publish_to: none
environment: environment:
sdk: ">=3.0.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"
dependencies: dependencies:
angel3_auth: ^8.0.0 angel3_auth: ^8.0.0
angel3_framework: ^8.0.0 angel3_framework: ^8.0.0

View file

@ -1,5 +1,10 @@
# Change Log # Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1 ## 8.1.1
* Updated repository link * Updated repository link

View file

@ -1,10 +1,10 @@
name: angel3_cache name: angel3_cache
version: 8.1.1 version: 8.2.0
description: A service that provides HTTP caching to the response data for Angel3 description: A service that provides HTTP caching to the response data for Angel3
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/cache repository: https://github.com/dart-backend/angel/tree/master/packages/cache
environment: environment:
sdk: '>=3.3.0 <4.0.0' sdk: '>=3.4.0 <4.0.0'
dependencies: dependencies:
angel3_framework: ^8.0.0 angel3_framework: ^8.0.0
collection: ^1.17.0 collection: ^1.17.0

View file

@ -1,5 +1,10 @@
# Change Log # Change Log
## 8.4.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.3.2 ## 8.3.2
* Updated README * Updated README

View file

@ -1,5 +1,5 @@
name: angel3_framework name: angel3_framework
version: 8.3.2 version: 8.4.0
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/framework repository: https://github.com/dart-backend/angel/tree/master/packages/framework

View file

@ -3,7 +3,8 @@
## 8.2.0 ## 8.2.0
* Require Dart >= 3.3 * Require Dart >= 3.3
* Upgraded `mongo_dart` to 0.10.2 * Updated `mongo_dart` to 0.10.2
* Updated `lints` to 3.0.0
* Fixed deprecated methods * Fixed deprecated methods
## 8.1.1 ## 8.1.1

View file

@ -1,5 +1,11 @@
# Change Log # Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
* Updated `web_socket_channel` to 3.0.0
## 8.1.1 ## 8.1.1
* Updated repository link * Updated repository link

View file

@ -93,7 +93,7 @@ abstract class BaseWebSocketClient extends BaseAngelClient {
Future close() async { Future close() async {
on._close(); on._close();
scheduleMicrotask(() async { scheduleMicrotask(() async {
await _socket!.sink.close(status.goingAway); await _socket!.sink.close(status.normalClosure);
await _onData.close(); await _onData.close();
await _onAllEvents.close(); await _onAllEvents.close();
await _onAuthenticated.close(); await _onAuthenticated.close();

View file

@ -508,8 +508,8 @@ class AngelWebSocket {
if (protocol != null) sink.add('Sec-WebSocket-Protocol: $protocol\r\n'); if (protocol != null) sink.add('Sec-WebSocket-Protocol: $protocol\r\n');
sink.add('\r\n'); sink.add('\r\n');
var ws = WebSocketChannel(ctrl.foreign); //var ws = IOWebSocketChannel.connect(ctrl.foreign);
var socket = WebSocketContext(ws, req, res); var socket = WebSocketContext(ctrl.foreign, req, res);
scheduleMicrotask(() => handleClient(socket)); scheduleMicrotask(() => handleClient(socket));
return false; return false;
} }

View file

@ -1,5 +1,5 @@
name: angel3_websocket name: angel3_websocket
version: 8.1.1 version: 8.2.0
description: This library provides WebSockets support for Angel3 framework. description: This library provides WebSockets support for Angel3 framework.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/websocket repository: https://github.com/dart-backend/angel/tree/master/packages/websocket
@ -14,14 +14,14 @@ dependencies:
http: ^1.0.0 http: ^1.0.0
meta: ^1.8.0 meta: ^1.8.0
stream_channel: ^2.1.0 stream_channel: ^2.1.0
web_socket_channel: '>=2.1.0 <2.4.1' web_socket_channel: ^3.0.0
collection: ^1.17.0 collection: ^1.17.0
logging: ^1.1.0 logging: ^1.1.0
dev_dependencies: dev_dependencies:
angel3_container: ^8.0.0 angel3_container: ^8.0.0
angel3_model: ^8.0.0 angel3_model: ^8.0.0
quiver: ^3.2.0 quiver: ^3.2.0
test: ^1.24.0 test: ^1.25.0
lints: ^4.0.0 lints: ^4.0.0
file: ^7.0.0 file: ^7.0.0
# dependency_overrides: # dependency_overrides:

View file

@ -11,7 +11,7 @@ import 'common.dart';
void main() { void main() {
srv.Angel app; srv.Angel app;
late srv.AngelHttp http; late srv.AngelHttp http;
ws.WebSockets? client; late ws.WebSockets client;
srv.AngelWebSocket websockets; srv.AngelWebSocket websockets;
HttpServer? server; HttpServer? server;
String? url; String? url;
@ -34,12 +34,12 @@ void main() {
url = 'ws://${server!.address.address}:${server!.port}/ws'; url = 'ws://${server!.address.address}:${server!.port}/ws';
client = ws.WebSockets(url); client = ws.WebSockets(url);
await client!.connect(timeout: Duration(seconds: 3)); await client.connect(timeout: Duration(seconds: 3));
print('Connected'); print('Connected');
client client
?..onData.listen((data) { ..onData.listen((data) {
print('Received by client: $data'); print('Received by client: $data');
}) })
..onError.listen((error) { ..onError.listen((error) {
@ -51,18 +51,17 @@ void main() {
}); });
tearDown(() async { tearDown(() async {
await client!.close(); await client.close();
await http.close(); await http.close();
//app = null; //app = null;
client = null;
server = null; server = null;
url = null; url = null;
}); });
group('controller.io', () { group('controller.io', () {
test('search', () async { test('search', () async {
client!.sendAction(ws.WebSocketAction(eventName: 'search')); client.sendAction(ws.WebSocketAction(eventName: 'search'));
var search = await client!.on['searched'].first; var search = await client.on['searched'].first;
print('Searched: ${search.data}'); print('Searched: ${search.data}');
expect(Game.fromJson(search.data as Map), equals(johnVsBob)); expect(Game.fromJson(search.data as Map), equals(johnVsBob));
}); });