GH-240: Warn if not connected to the Internet.

Make sure the gRPC client initialization is rejected.

Closes #240.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-04-27 14:41:57 +02:00
parent f1fca4d5b3
commit d8a742e440
2 changed files with 6 additions and 4 deletions

View File

@@ -38,14 +38,12 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
const initReq = new InitReq();
initReq.setLibraryManagerOnly(false);
const initResp = await new Promise<InitResp>(resolve => {
const initResp = await new Promise<InitResp>((resolve, reject) => {
let resp: InitResp | undefined = undefined;
const stream = client.init(initReq);
stream.on('data', (data: InitResp) => resp = data);
stream.on('end', () => resolve(resp));
stream.on('error', err => {
console.log('init error', err)
});
stream.on('error', err => reject(err));
});
const instance = initResp.getInstance();