sendRequest method
Send a request
to the server in the form of an ApiRequest.
Throws a StateError if the client is disconnected.
Implementation
void sendRequest(ApiRequest request) {
if (!_hasConnected) {
throw StateError('Client is not connected');
}
_socket.add(request.toIntList());
}