io.grpc.okhttp.OkHttpChannelProvider Java Examples
The following examples show how to use
io.grpc.okhttp.OkHttpChannelProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpeechService.java From black-mirror with MIT License | 6 votes |
@Override protected void onPostExecute(AccessToken accessToken) { mAccessTokenTask = null; final ManagedChannel channel = new OkHttpChannelProvider() .builderForAddress(HOSTNAME, PORT) .nameResolverFactory(new DnsNameResolverProvider()) .intercept(new GoogleCredentialsInterceptor(new GoogleCredentials(accessToken) .createScoped(SCOPE))) .build(); mApi = SpeechGrpc.newStub(channel); // Schedule access token refresh before it expires if (mHandler != null) { mHandler.postDelayed(mFetchAccessTokenRunnable, Math.max(accessToken.getExpirationTime().getTime() - System.currentTimeMillis() - ACCESS_TOKEN_FETCH_MARGIN, ACCESS_TOKEN_EXPIRATION_TOLERANCE)); } }
Example #2
Source File: SpeechService.java From android-docs-samples with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(AccessToken accessToken) { mAccessTokenTask = null; final ManagedChannel channel = new OkHttpChannelProvider() .builderForAddress(HOSTNAME, PORT) .nameResolverFactory(new DnsNameResolverProvider()) .intercept(new GoogleCredentialsInterceptor(new GoogleCredentials(accessToken) .createScoped(SCOPE))) .build(); mApi = SpeechGrpc.newStub(channel); // Schedule access token refresh before it expires if (mHandler != null) { mHandler.postDelayed(mFetchAccessTokenRunnable, Math.max(accessToken.getExpirationTime().getTime() - System.currentTimeMillis() - ACCESS_TOKEN_FETCH_MARGIN, ACCESS_TOKEN_EXPIRATION_TOLERANCE)); } }