Beispiel #1
0
    /// <summary>
    /// This method handles the task of calling the remote gRPC Service ListFeatures by passing a Message Type of
    /// Rectangle which contains (2) Points. The result is a gRPC response STREAM of Feature Message Types.
    /// </summary>
    /// <param name="areaOfInterest">A Routeguide Rectangle containing two Points</param>
    /// <returns></returns>
    public async Task ListFeatures(Routeguide.Rectangle areaOfInterest)
    {
        Debug.Log("ListFeatures Client Lo latitude: " + areaOfInterest.Lo.Latitude +
                  ",  Lo longitude: " + areaOfInterest.Lo.Longitude + "\n" +
                  ",  Hi latitude: " + areaOfInterest.Hi.Latitude +
                  ",  Hi longitude: " + areaOfInterest.Hi.Longitude);

        StringBuilder responseText = new StringBuilder();

        try
        {
            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
            //Sending and Receiving will be sequential - send first, then receive stream response second
            var response = _client.ListFeatures(areaOfInterest, cancellationToken: cts.Token);
            while (await response.ResponseStream.MoveNext())
            {
                var thisItemName = response.ResponseStream.Current.Name;
                if (!String.IsNullOrEmpty(thisItemName))
                {
                    _myRouteGuideUiHandler.AddTextToUi(thisItemName, false);
                }
            }
        }
        catch (RpcException e)
        {
            _myRouteGuideUiHandler.AddTextToUi("ListFeatures Service is unavailable. " + e.Message, false);
        }

#if DEBUG
        Debug.Log("async Task ListFeatures Finished");
#endif
    }
Beispiel #2
0
    /// <summary>
    /// This method front ends a gRPC client method which makes a call to the remote gRPC server, passing a SET of
    /// Two POINTs within a Rectangle Message Type.
    /// The response from the gRPC server is an asynchronous STREAM of Feature Message types
    /// Essentially - Single Client REQUEST/Server-side asynchronous response STREAM
    /// </summary>
    public async void GetMultipleFeatures()
    {
        ClearTMPTextChildren();

        var pointOfInterestLo = new Routeguide.Point {
            Latitude = 400000000, Longitude = -750000000
        };
        var pointOfInterestHi = new Routeguide.Point {
            Latitude = 420000000, Longitude = -730000000
        };

        var areaOfInterest = new Routeguide.Rectangle
        {
            Lo = pointOfInterestLo,
            Hi = pointOfInterestHi,
        };

        await _routeGuideClient.ListFeatures(areaOfInterest);

        Debug.Log("GetMultipleFeatures Finished");
    }