GrpcServiceManager constructor
GrpcServiceManager(
{ - String host = 'localhost',
- int port = 50051,
- bool secure = false,
})
Implementation
GrpcServiceManager({
String host = 'localhost',
int port = 50051,
bool secure = false,
}) {
final credentials = secure
? ChannelCredentials.secure()
: ChannelCredentials.insecure();
if (isRunningOnWeb()) {
// gRPC-web: browser gestisce già la compressione HTTP,
// .grpc() non è supportato su web.
_channel = GrpcOrGrpcWebClientChannel.toSingleEndpoint(
host: host,
port: port,
transportSecure: secure,
);
} else {
// Native: abilita codecRegistry per decomprimere le risposte.
_channel = GrpcOrGrpcWebClientChannel.grpc(
host,
port: port,
options: ChannelOptions(
credentials: credentials,
codecRegistry: CodecRegistry(codecs: [GzipCodec()]),
),
);
}
}