softplayer-web/lib/api/grpc/environments.dart

42 lines
868 B
Dart
Raw Normal View History

2024-04-19 11:19:44 +00:00
import 'dart:html';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_dart_proto/main.dart';
class EnvironmentLocalData {
EnvironmentLocalData({
required this.uuid,
required this.token,
});
String uuid;
String token;
}
class EnvironmentsGrpc {
final GrpcWebClientChannel channel;
late EnvironmentsClient envStub;
EnvironmentsGrpc({
required this.channel,
});
void init() {
envStub = EnvironmentsClient(channel);
}
Stream<List<String>> list() async* {
List<String> envs = [];
try {
await for (var feature in envStub.list(Empty(),
options: CallOptions(metadata: {
"uuid": window.localStorage["uuid"]!,
"token": window.localStorage["token"]!,
}))) {
envs.add(feature.data.name);
}
} catch (e) {
rethrow;
}
yield envs;
}
}