From 54d3990536f1f0ce5a204e618db1e0f427537c11 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Sun, 12 May 2024 08:24:59 +0400 Subject: [PATCH] Add asserts --- lib/src/spinify_impl.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/spinify_impl.dart b/lib/src/spinify_impl.dart index fa5c42b..0f45917 100644 --- a/lib/src/spinify_impl.dart +++ b/lib/src/spinify_impl.dart @@ -117,6 +117,10 @@ base mixin SpinifyCommandMixin on SpinifyBase { Future _sendCommand(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(); await _sendCommandAsync(command); return await completer.future.timeout(config.timeout); @@ -131,6 +135,7 @@ base mixin SpinifyCommandMixin on SpinifyBase { Future _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); }