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); }