-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add benchmarks * Update table formatting in README.md for improved readability * Consolidate Flutter and Dart versions in README.md for better clarity * Add benchmark information * Add benchmark description * Update example * Add custom configuration for Spinify client in README.md and example * Add subscription example and update README for clarity * Clarify JSON codec support limitation in README * Update README.md * Update README.md * Update package info
- Loading branch information
Showing
7 changed files
with
206 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,54 @@ | ||
// ignore_for_file: avoid_print | ||
// ignore_for_file: avoid_print, implicit_call_tearoffs | ||
|
||
import 'dart:async'; | ||
import 'dart:io' as io; | ||
|
||
import 'package:spinify/spinify.dart'; | ||
|
||
void main(List<String> args) { | ||
void main(List<String> args) async { | ||
var url = args.firstWhere((a) => a.startsWith('--url='), orElse: () => ''); | ||
if (url.isNotEmpty) url = url.substring(6).trim(); | ||
if (url.isEmpty) url = io.Platform.environment['URL'] ?? ''; | ||
if (url.isEmpty) url = const String.fromEnvironment('URL', defaultValue: ''); | ||
if (url.isEmpty) url = 'ws://localhost:8000/connection/websocket'; | ||
|
||
final httpClient = io.HttpClient( | ||
context: io.SecurityContext( | ||
withTrustedRoots: true, | ||
), //..setTrustedCertificatesBytes([/* bytes array */]) | ||
); | ||
|
||
final client = Spinify( | ||
config: SpinifyConfig( | ||
client: (name: 'app', version: '1.0.0'), | ||
timeout: const Duration(seconds: 15), | ||
serverPingDelay: const Duration(seconds: 8), | ||
connectionRetryInterval: ( | ||
min: const Duration(milliseconds: 250), | ||
max: const Duration(seconds: 15), | ||
), | ||
/* getToken: () async => '<token>', */ | ||
/* getPayload: () async => utf8.encode('Hello, World!'), */ | ||
codec: SpinifyProtobufCodec(), | ||
transportBuilder: SpinifyTransportAdapter.vm( | ||
compression: io.CompressionOptions.compressionDefault, | ||
customClient: httpClient, | ||
userAgent: 'Dart', | ||
), | ||
logger: (level, event, message, context) => print('[$event] $message'), | ||
), | ||
); | ||
|
||
Timer(const Duration(minutes: 1), () async { | ||
await client.close(); | ||
io.exit(0); | ||
}); | ||
|
||
var prev = client.state; | ||
client.states.listen((next) { | ||
print('$prev -> $next'); | ||
prev = next; | ||
}); | ||
|
||
client.connect(url).ignore(); | ||
await client.connect(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters