Skip to content

Commit

Permalink
Add asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed May 12, 2024
1 parent 076aec1 commit 54d3990
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/src/spinify_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ base mixin SpinifyCommandMixin on SpinifyBase {

Future<T> _sendCommand<T extends SpinifyReply>(SpinifyCommand command) async {
try {
assert(command.id > -1, 'Command ID should be greater or equal to 0');
assert(_replies[command.id] == null, 'Command ID should be unique');
assert(_transport != null, 'Transport is not connected');
assert(state.isConnected, 'State is not connected');
final completer = _replies[command.id] = Completer<T>();
await _sendCommandAsync(command);
return await completer.future.timeout(config.timeout);
Expand All @@ -131,6 +135,7 @@ base mixin SpinifyCommandMixin on SpinifyBase {
Future<void> _sendCommandAsync(SpinifyCommand command) async {
assert(command.id > -1, 'Command ID should be greater or equal to 0');
assert(_transport != null, 'Transport is not connected');
assert(state.isConnected, 'State is not connected');
await _transport?.send(command);
}

Expand Down

0 comments on commit 54d3990

Please sign in to comment.