| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| // This file was auto-generated by the vanadium vdl tool. |
| |
| // Source(s): media.vdl |
| package io.v.x.media_sharing; |
| |
| /** |
| * Implementation of the {@link MediaSharingClient} interface. |
| */ |
| final class MediaSharingClientImpl implements io.v.x.media_sharing.MediaSharingClient { |
| private final io.v.v23.rpc.Client client; |
| private final java.lang.String vName; |
| |
| |
| |
| |
| /** |
| * Creates a new instance of {@link MediaSharingClientImpl}. |
| * |
| * @param client Vanadium client |
| * @param vName remote server name |
| */ |
| public MediaSharingClientImpl(io.v.v23.rpc.Client client, java.lang.String vName) { |
| this.client = client; |
| this.vName = vName; |
| |
| |
| } |
| |
| private io.v.v23.rpc.Client getClient(io.v.v23.context.VContext context) { |
| return this.client != null ? client : io.v.v23.V.getClient(context); |
| |
| } |
| |
| // Methods from interface MediaSharingClient. |
| |
| |
| |
| @Override |
| public void displayUrl(io.v.v23.context.VContext context, final java.lang.String url) throws io.v.v23.verror.VException { |
| displayUrl(context, url, null); |
| } |
| |
| @Override |
| public void displayUrl(io.v.v23.context.VContext context, final java.lang.String url, io.v.v23.Options vOpts) throws io.v.v23.verror.VException { |
| |
| // Start the call. |
| java.lang.Object[] _args = new java.lang.Object[]{ url }; |
| java.lang.reflect.Type[] _argTypes = new java.lang.reflect.Type[]{ new com.google.common.reflect.TypeToken<java.lang.String>(){}.getType() }; |
| final io.v.v23.rpc.Client.Call _call = getClient(context).startCall(context, this.vName, "displayUrl", _args, _argTypes, vOpts); |
| |
| // Finish the call. |
| |
| |
| |
| |
| java.lang.reflect.Type[] _resultTypes = new java.lang.reflect.Type[]{}; |
| _call.finish(_resultTypes); |
| |
| |
| |
| } |
| |
| |
| @Override |
| public io.v.v23.vdl.ClientStream<byte[], java.lang.Void, java.lang.Void> displayBytes(io.v.v23.context.VContext context, final java.lang.String mediaType) throws io.v.v23.verror.VException { |
| return displayBytes(context, mediaType, null); |
| } |
| |
| @Override |
| public io.v.v23.vdl.ClientStream<byte[], java.lang.Void, java.lang.Void> displayBytes(io.v.v23.context.VContext context, final java.lang.String mediaType, io.v.v23.Options vOpts) throws io.v.v23.verror.VException { |
| |
| // Start the call. |
| java.lang.Object[] _args = new java.lang.Object[]{ mediaType }; |
| java.lang.reflect.Type[] _argTypes = new java.lang.reflect.Type[]{ new com.google.common.reflect.TypeToken<java.lang.String>(){}.getType() }; |
| final io.v.v23.rpc.Client.Call _call = getClient(context).startCall(context, this.vName, "displayBytes", _args, _argTypes, vOpts); |
| |
| // Finish the call. |
| |
| |
| return new io.v.v23.vdl.ClientStream<byte[], java.lang.Void, java.lang.Void>() { |
| @Override |
| public void send(byte[] item) throws io.v.v23.verror.VException { |
| java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<byte[]>() {}.getType(); |
| _call.send(item, type); |
| } |
| @Override |
| public java.lang.Void recv() throws java.io.EOFException, io.v.v23.verror.VException { |
| java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<java.lang.Void>() {}.getType(); |
| java.lang.Object result = _call.recv(type); |
| try { |
| return (java.lang.Void)result; |
| } catch (java.lang.ClassCastException e) { |
| throw new io.v.v23.verror.VException("Unexpected result type: " + result.getClass().getCanonicalName()); |
| } |
| } |
| @Override |
| public java.lang.Void finish() throws io.v.v23.verror.VException { |
| |
| java.lang.reflect.Type[] resultTypes = new java.lang.reflect.Type[]{}; |
| _call.finish(resultTypes); |
| return null; |
| |
| } |
| }; |
| |
| } |
| |
| |
| |
| |
| |
| } |