aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-10-05 10:18:05 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-10-05 10:18:05 -0700
commitb0f3bf16cee1d893fc0414fcfe1060baac4eaa9b (patch)
tree747298bf60f8a0b1c519a33d6084fad42fc192de /examples
parent350835a9566a4b56bfd409108ec235ef2424b630 (diff)
parenta9154a36fbc019b87f4d62ce16b346f3d44ec2de (diff)
Resolved merge conflicts with master
Diffstat (limited to 'examples')
-rw-r--r--examples/csharp/helloworld/.nuget/packages.config2
-rw-r--r--examples/csharp/helloworld/Greeter/Greeter.csproj14
-rw-r--r--examples/csharp/helloworld/Greeter/packages.config6
-rw-r--r--examples/csharp/helloworld/GreeterClient/GreeterClient.csproj14
-rw-r--r--examples/csharp/helloworld/GreeterClient/packages.config6
-rw-r--r--examples/csharp/helloworld/GreeterServer/GreeterServer.csproj14
-rw-r--r--examples/csharp/helloworld/GreeterServer/packages.config6
-rw-r--r--examples/csharp/helloworld/README.md46
-rw-r--r--examples/csharp/route_guide/.nuget/packages.config2
-rw-r--r--examples/csharp/route_guide/README.md388
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.csproj16
-rw-r--r--examples/csharp/route_guide/RouteGuide/packages.config8
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/App.config6
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj19
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/packages.config7
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/App.config6
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj19
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/packages.config7
-rw-r--r--examples/node/README.md19
-rw-r--r--examples/node/route_guide/README.md364
-rw-r--r--examples/php/README.md3
-rw-r--r--examples/php/composer.json2
-rw-r--r--examples/php/greeter_client.php3
-rw-r--r--examples/php/helloworld.php14
-rw-r--r--examples/php/route_guide/README.md264
-rw-r--r--examples/php/route_guide/route_guide.php2
-rw-r--r--examples/php/route_guide/route_guide_client.php45
-rwxr-xr-xexamples/php/route_guide/run_route_guide_client.sh4
-rwxr-xr-xexamples/php/run_greeter_client.sh5
-rw-r--r--examples/ruby/Gemfile2
-rw-r--r--examples/ruby/README.md8
-rwxr-xr-xexamples/ruby/greeter_server.rb4
-rw-r--r--examples/ruby/grpc-demo.gemspec4
-rw-r--r--examples/ruby/lib/route_guide.rb30
-rw-r--r--examples/ruby/lib/route_guide_services.rb6
-rw-r--r--examples/ruby/route_guide/README.md287
-rwxr-xr-xexamples/ruby/route_guide/route_guide_client.rb2
-rwxr-xr-xexamples/ruby/route_guide/route_guide_server.rb6
38 files changed, 188 insertions, 1472 deletions
diff --git a/examples/csharp/helloworld/.nuget/packages.config b/examples/csharp/helloworld/.nuget/packages.config
index e2879c1893..1c1f118d46 100644
--- a/examples/csharp/helloworld/.nuget/packages.config
+++ b/examples/csharp/helloworld/.nuget/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Grpc.Tools" version="0.7.0" />
+ <package id="Grpc.Tools" version="0.7.1" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj
index 3d92c4bf25..2ae8620267 100644
--- a/examples/csharp/helloworld/Greeter/Greeter.csproj
+++ b/examples/csharp/helloworld/Greeter/Greeter.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
@@ -13,7 +13,7 @@
<RootNamespace>Greeter</RootNamespace>
<AssemblyName>Greeter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>3ef64a6a</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>e423e365</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,9 +37,9 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Interactive.Async">
@@ -65,10 +65,10 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config
index 1273624cbd..c0f7387916 100644
--- a/examples/csharp/helloworld/Greeter/packages.config
+++ b/examples/csharp/helloworld/Greeter/packages.config
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
index 7874172bf2..af330f2b90 100644
--- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
+++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterClient</RootNamespace>
<AssemblyName>GreeterClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>c4057b0a</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>2dcf22af</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,9 +37,9 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Interactive.Async">
@@ -68,10 +68,10 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config
index 1273624cbd..c0f7387916 100644
--- a/examples/csharp/helloworld/GreeterClient/packages.config
+++ b/examples/csharp/helloworld/GreeterClient/packages.config
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
index d1db2f4773..752f32828b 100644
--- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
+++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterServer</RootNamespace>
<AssemblyName>GreeterServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>cc15afe5</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>53a3a588</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,9 +37,9 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Interactive.Async">
@@ -68,10 +68,10 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config
index 1273624cbd..c0f7387916 100644
--- a/examples/csharp/helloworld/GreeterServer/packages.config
+++ b/examples/csharp/helloworld/GreeterServer/packages.config
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/README.md b/examples/csharp/helloworld/README.md
index 3719080f4a..f1af1f6793 100644
--- a/examples/csharp/helloworld/README.md
+++ b/examples/csharp/helloworld/README.md
@@ -3,49 +3,52 @@ gRPC in 3 minutes (C#)
BACKGROUND
-------------
-For this sample, we've already generated the server and client stubs from `helloworld.proto`.
-Example projects depend on NuGet packages `Grpc` and `Google.ProtocolBuffers` which have been already added to the project for you.
+For this sample, we've already generated the server and client stubs from [helloworld.proto][].
+
+Example projects depend on the [Grpc](https://www.nuget.org/packages/Grpc/)
+and [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf/) NuGet packages
+which have been already added to the project for you.
PREREQUISITES
-------------
**Windows**
- .NET 4.5+
-- VS 2013 (with NuGet plugin installed)
+- Visual Studio 2013 or 2015
-**Linux (Mono)**
+**Linux**
- Mono
-- Monodevelop 5.9 with NuGet Add-in installed (older versions might work)
+- Monodevelop 5.9 with NuGet Add-in installed
-**MacOS (Mono)**
+**Mac OS X**
- Xamarin Studio (with NuGet plugin installed)
+- [homebrew][]
BUILD
-------
**Windows**
-- Clone this repository.
- Open solution `Greeter.sln` with Visual Studio
- Build the solution (this will automatically download NuGet dependencies)
-**Linux (Mono)**
-- Clone this repository.
+**Linux (Debian)**
+
+- Install gRPC C core and C# native extension using [How to use gRPC C#][] instructions
-- Install gRPC C Core using instructions in https://github.com/grpc/homebrew-grpc
+- Open solution `Greeter.sln` in MonoDevelop.
-- gRPC C# depends on native shared library `libgrpc_csharp_ext.so`. To make it visible
- to Mono runtime, follow instructions in [Using gRPC C# on Linux](https://github.com/grpc/grpc/tree/master/src/csharp#usage-linux-mono)
+- Build the solution (you need to manually restore dependencies by using `mono nuget.exe restore` if you don't have NuGet add-in)
-- Open solution `Greeter.sln` in MonoDevelop (you need to manually restore dependencies by using `mono nuget.exe restore` if you don't have NuGet add-in)
+**Mac OS X**
-- Build the solution.
+- Install gRPC C core and C# native extension using [How to use gRPC C#][] instructions
-**MacOS (Mono)**
-- See [Using gRPC C# on MacOS](https://github.com/grpc/grpc/tree/master/src/csharp#usage-macos-mono) for more info
- on MacOS support.
+- Open solution `Greeter.sln` with Xamarin Studio
-Try it!
+- Build the solution (this will automatically download NuGet dependencies)
+
+Try it!
-------
- Run the server
@@ -69,4 +72,9 @@ On Linux or Mac, use `mono GreeterServer.exe` and `mono GreeterClient.exe` to ru
Tutorial
--------
-You can find a more detailed tutorial in [gRPC Basics: C#](route_guide/README.md)
+You can find a more detailed tutorial in [gRPC Basics: C#][]
+
+[homebrew]:http://brew.sh
+[helloworld.proto]:../../protos/helloworld.proto
+[How to use gRPC C#]:../../../src/csharp#how-to-use
+[gRPC Basics: C#]:http://www.grpc.io/docs/tutorials/basic/csharp.html
diff --git a/examples/csharp/route_guide/.nuget/packages.config b/examples/csharp/route_guide/.nuget/packages.config
index e2879c1893..1c1f118d46 100644
--- a/examples/csharp/route_guide/.nuget/packages.config
+++ b/examples/csharp/route_guide/.nuget/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Grpc.Tools" version="0.7.0" />
+ <package id="Grpc.Tools" version="0.7.1" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/README.md b/examples/csharp/route_guide/README.md
index 155877e62e..a9aa87a83d 100644
--- a/examples/csharp/route_guide/README.md
+++ b/examples/csharp/route_guide/README.md
@@ -1,386 +1,6 @@
-#gRPC Basics: C# #
+#gRPC Basics: C# sample code
-This tutorial provides a basic C# programmer's introduction to working with gRPC. By walking through this example you'll learn how to:
+The files in this folder are the samples used in [gRPC Basics: C#][],
+a detailed tutorial for using gRPC in C#.
-- Define a service in a .proto file.
-- Generate server and client code using the protocol buffer compiler.
-- Use the C# gRPC API to write a simple client and server for your service.
-
-It assumes that you have read the [Getting started](https://github.com/grpc/grpc/tree/master/examples) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial only uses the proto2 version of the protocol buffers language, as proto3 support for C# is not ready yet (see [protobuf C# README](https://github.com/google/protobuf/tree/master/csharp#proto2--proto3)).
-
-This isn't a comprehensive guide to using gRPC in C#: more reference documentation is coming soon.
-
-## Why use gRPC?
-
-Our example is a simple route mapping application that lets clients get information about features on their route, create a summary of their route, and exchange route information such as traffic updates with the server and other clients.
-
-With gRPC we can define our service once in a .proto file and implement clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet - all the complexity of communication between different languages and environments is handled for you by gRPC. We also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL, and easy interface updating.
-
-## Example code and setup
-
-The example code for our tutorial is in [examples/csharp/route_guide](.). To download the example, clone this repository by running the following command:
-```shell
-$ git clone https://github.com/grpc/grpc.git
-```
-
-All the files for this tutorial are in the directory `examples/csharp/route_guide`.
-Open the solution `examples/csharp/route_guide/RouteGuide.sln` from Visual Studio (or Monodevelop on Linux).
-
-On Windows, you should not need to do anything besides opening the solution. All the needed dependencies will be restored
-for you automatically by the `Grpc` NuGet package upon building the solution.
-
-On Linux (or MacOS), you will first need to install protobuf and gRPC C Core using Linuxbrew (or Homebrew) tool in order to be
-able to generate the server and client interface code and run the examples. Follow the instructions for [Linux](https://github.com/grpc/grpc/tree/master/src/csharp#usage-linux-mono) or [MacOS](https://github.com/grpc/grpc/tree/master/src/csharp#usage-macos-mono).
-
-## Defining the service
-
-Our first step (as you'll know from [Getting started](https://github.com/grpc/grpc/tree/master/examples)) is to define the gRPC *service* and the method *request* and *response* types using [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in [`RouteGuide/protos/route_guide.proto`](RouteGuide/protos/route_guide.proto).
-
-To define a service, you specify a named `service` in your .proto file:
-
-```protobuf
-service RouteGuide {
- ...
-}
-```
-
-Then you define `rpc` methods inside your service definition, specifying their request and response types. gRPC lets you define four kinds of service method, all of which are used in the `RouteGuide` service:
-
-- A *simple RPC* where the client sends a request to the server using the stub and waits for a response to come back, just like a normal function call.
-```protobuf
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-```
-
-- A *server-side streaming RPC* where the client sends a request to the server and gets a stream to read a sequence of messages back. The client reads from the returned stream until there are no more messages. As you can see in our example, you specify a server-side streaming method by placing the `stream` keyword before the *response* type.
-```protobuf
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-```
-
-- A *client-side streaming RPC* where the client writes a sequence of messages and sends them to the server, again using a provided stream. Once the client has finished writing the messages, it waits for the server to read them all and return its response. You specify a server-side streaming method by placing the `stream` keyword before the *request* type.
-```protobuf
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-```
-
-- A *bidirectional streaming RPC* where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved. You specify this type of method by placing the `stream` keyword before both the request and the response.
-```protobuf
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-```
-
-Our .proto file also contains protocol buffer message type definitions for all the request and response types used in our service methods - for example, here's the `Point` message type:
-```protobuf
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- int32 latitude = 1;
- int32 longitude = 2;
-}
-```
-
-
-## Generating client and server code
-
-Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler `protoc` with a special gRPC C# plugin.
-
-If you want to run this yourself, make sure you've installed protoc and gRPC C# plugin. The instructions vary based on your OS:
-- For Windows, the `Grpc.Tools` and `Google.Protobuf` NuGet packages contain the binaries you will need to generate the code.
-- For Linux, make sure you've [installed gRPC C Core using Linuxbrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-linux-mono)
-- For MacOS, make sure you've [installed gRPC C Core using Homebrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-macos-mono)
-
-Once that's done, the following command can be used to generate the C# code.
-
-To generate the code on Windows, we use `protoc.exe` from the `Google.Protobuf` NuGet package and `grpc_csharp_plugin.exe` from the `Grpc.Tools` NuGet package (both under the `tools` directory).
-Normally you would need to add the `Grpc.Tools` package to the solution yourself, but in this tutorial it has been already done for you. Following command should be run from the `csharp/route_guide` directory:
-```
-> packages\Google.Protobuf.3.0.0-alpha4\tools\protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe RouteGuide/protos/route_guide.proto
-```
-
-On Linux/MacOS, we rely on `protoc` and `grpc_csharp_plugin` being installed by Linuxbrew/Homebrew. Run this command from the route_guide directory:
-```shell
-$ protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` RouteGuide/protos/route_guide.proto
-```
-
-Running one of the previous commands regenerates the following files in the RouteGuide directory:
-- `RouteGuide/RouteGuide.cs` defines a namespace `examples`
- - This contains all the protocol buffer code to populate, serialize, and retrieve our request and response message types
-- `RouteGuide/RouteGuideGrpc.cs`, provides stub and service classes
- - an interface `RouteGuide.IRouteGuide` to inherit from when defining RouteGuide service implementations
- - a class `RouteGuide.RouteGuideClient` that can be used to access remote RouteGuide instances
-
-
-<a name="server"></a>
-## Creating the server
-
-First let's look at how we create a `RouteGuide` server. If you're only interested in creating gRPC clients, you can skip this section and go straight to [Creating the client](#client) (though you might find it interesting anyway!).
-
-There are two parts to making our `RouteGuide` service do its job:
-- Implementing the service interface generated from our service definition: doing the actual "work" of our service.
-- Running a gRPC server to listen for requests from clients and return the service responses.
-
-You can find our example `RouteGuide` server in [RouteGuideServer/RouteGuideImpl.cs](RouteGuideServer/RouteGuideServerImpl.cs). Let's take a closer look at how it works.
-
-### Implementing RouteGuide
-
-As you can see, our server has a `RouteGuideImpl` class that implements the generated `RouteGuide.IRouteGuide`:
-
-```csharp
-// RouteGuideImpl provides an implementation of the RouteGuide service.
-public class RouteGuideImpl : RouteGuide.IRouteGuide
-```
-
-#### Simple RPC
-
-`RouteGuideImpl` implements all our service methods. Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
-
-```csharp
- public Task<Feature> GetFeature(Point request, Grpc.Core.ServerCallContext context)
- {
- return Task.FromResult(CheckFeature(request));
- }
-```
-
-The method is passed a context for the RPC (which is empty in the alpha release), the client's `Point` protocol buffer request, and returns a `Feature` protocol buffer. In the method we create the `Feature` with the appropriate information, and then return it. To allow asynchronous
-implementation, the method returns `Task<Feature>` rather than just `Feature`. You are free to perform your computations synchronously and return
-the result once you've finished, just as we do in the example.
-
-#### Server-side streaming RPC
-
-Now let's look at something a bit more complicated - a streaming RPC. `ListFeatures` is a server-side streaming RPC, so we need to send back multiple `Feature` protocol buffers to our client.
-
-```csharp
- // in RouteGuideImpl
- public async Task ListFeatures(Rectangle request,
- Grpc.Core.IServerStreamWriter<Feature> responseStream,
- Grpc.Core.ServerCallContext context)
- {
- var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
- foreach (var response in responses)
- {
- await responseStream.WriteAsync(response);
- }
- }
-```
-
-As you can see, here the request object is a `Rectangle` in which our client wants to find `Feature`s, but instead of returning a simple response we need to write responses to an asynchronous stream `IServerStreamWriter` using async method `WriteAsync`.
-
-#### Client-side streaming RPC
-
-Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumerator](https://github.com/Reactive-Extensions/Rx.NET/blob/master/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs), to read the stream of requests using the async method `MoveNext` and the `Current` property.
-
-```csharp
- public async Task<RouteSummary> RecordRoute(Grpc.Core.IAsyncStreamReader<Point> requestStream,
- Grpc.Core.ServerCallContext context)
- {
- int pointCount = 0;
- int featureCount = 0;
- int distance = 0;
- Point previous = null;
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- while (await requestStream.MoveNext())
- {
- var point = requestStream.Current;
- pointCount++;
- if (CheckFeature(point).Exists())
- {
- featureCount++;
- }
- if (previous != null)
- {
- distance += (int) previous.GetDistance(point);
- }
- previous = point;
- }
-
- stopwatch.Stop();
-
- return new RouteSummary
- {
- PointCount = pointCount,
- FeatureCount = featureCount,
- Distance = distance,
- ElapsedTime = (int)(stopwatch.ElapsedMilliseconds / 1000)
- };
- }
-```
-
-#### Bidirectional streaming RPC
-
-Finally, let's look at our bidirectional streaming RPC `RouteChat`.
-
-```csharp
- public async Task RouteChat(Grpc.Core.IAsyncStreamReader<RouteNote> requestStream,
- Grpc.Core.IServerStreamWriter<RouteNote> responseStream,
- Grpc.Core.ServerCallContext context,)
- {
- while (await requestStream.MoveNext())
- {
- var note = requestStream.Current;
- List<RouteNote> prevNotes = AddNoteForLocation(note.Location, note);
- foreach (var prevNote in prevNotes)
- {
- await responseStream.WriteAsync(prevNote);
- }
- }
- }
-```
-
-Here the method receives both `requestStream` and `responseStream` arguments. Reading the requests is done the same way as in the client-side streaming method `RecordRoute`. Writing the responses is done the same way as in the server-side streaming method `ListFeatures`.
-
-### Starting the server
-
-Once we've implemented all our methods, we also need to start up a gRPC server so that clients can actually use our service. The following snippet shows how we do this for our `RouteGuide` service:
-
-```csharp
-var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
-
-Server server = new Server
-{
- Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
- Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
-};
-server.Start();
-
-Console.WriteLine("RouteGuide server listening on port " + port);
-Console.WriteLine("Press any key to stop the server...");
-Console.ReadKey();
-
-server.ShutdownAsync().Wait();
-```
-As you can see, we build and start our server using `Grpc.Core.Server` class. To do this, we:
-
-1. Create an instance of `Grpc.Core.Server`.
-1. Create an instance of our service implementation class `RouteGuideImpl`.
-3. Register our service implementation by adding its service definition to `Services` collection (We obtain the service definition from the generated `RouteGuide.BindService` method).
-2. Specify the address and port we want to use to listen for client requests. This is done by adding `ServerPort` to `Ports` collection.
-4. Call `Start` on the server instance to start an RPC server for our service.
-
-<a name="client"></a>
-## Creating the client
-
-In this section, we'll look at creating a C# client for our `RouteGuide` service. You can see our complete example client code in [RouteGuideClient/Program.cs](RouteGuideClient/Program.cs).
-
-### Creating a stub
-
-To call service methods, we first need to create a *stub*.
-
-First, we need to create a gRPC client channel that will connect to gRPC server. Then, we use the `RouteGuide.NewClient` method of the `RouteGuide` class generated from our .proto.
-
-```csharp
-Channel channel = new Channel("127.0.0.1:50052", Credentials.Insecure)
-var client = new RouteGuideClient(RouteGuide.NewClient(channel));
-
-// YOUR CODE GOES HERE
-
-channel.ShutdownAsync().Wait();
-```
-
-### Calling service methods
-
-Now let's look at how we call our service methods. gRPC C# provides asynchronous versions of each of the supported method types. For convenience,
-gRPC C# also provides a synchronous method stub, but only for simple (single request/single response) RPCs.
-
-#### Simple RPC
-
-Calling the simple RPC `GetFeature` in a synchronous way is nearly as straightforward as calling a local method.
-
-```csharp
-Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
-Feature feature = client.GetFeature(request);
-```
-
-As you can see, we create and populate a request protocol buffer object (in our case `Point`), and call the desired method on the client object, passing it the request. If the RPC finishes with success, the response protocol buffer (in our case `Feature`) will be returned. Otherwise, an exception of type `RpcException` will be thrown, indicating the status code of the problem.
-
-Alternatively, if you are in async context, you can call an asynchronous version of the method (and use `await` keyword to await the result):
-```csharp
-Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
-Feature feature = await client.GetFeatureAsync(request);
-```
-
-#### Streaming RPCs
-
-Now let's look at our streaming methods. If you've already read [Creating the server](#server) some of this may look very familiar - streaming RPCs are implemented in a similar way on both sides. The difference with respect to simple call is that the client methods return an instance of a call object, that provides access to request/response streams and/or asynchronous result (depending on the streaming type you are using).
-
-Here's where we call the server-side streaming method `ListFeatures`, which has property `ReponseStream` of type `IAsyncEnumerator<Feature>`
-
-```csharp
-using (var call = client.ListFeatures(request))
-{
- while (await call.ResponseStream.MoveNext())
- {
- Feature feature = call.ResponseStream.Current;
- Console.WriteLine("Received " + feature.ToString());
- }
-}
-```
-
-The client-side streaming method `RecordRoute` is similar, except we use the property `RequestStream` to write the requests one by one using `WriteAsync` and eventually signal that no more request will be send using `CompleteAsync`. The method result can be obtained through the property
-`ResponseAsync`.
-```csharp
-using (var call = client.RecordRoute())
-{
- foreach (var point in points)
- {
- await call.RequestStream.WriteAsync(point);
- }
- await call.RequestStream.CompleteAsync();
-
- RouteSummary summary = await call.ResponseAsync;
-}
-```
-
-Finally, let's look at our bidirectional streaming RPC `RouteChat`. In this case, we write the request to `RequestStream` and receive the responses from `ResponseStream`. As you can see from the example, the streams are independent of each other.
-
-```csharp
- using (var call = client.RouteChat())
- {
- var responseReaderTask = Task.Run(async () =>
- {
- while (await call.ResponseStream.MoveNext())
- {
- var note = call.ResponseStream.Current;
- Console.WriteLine("Received " + note);
- }
- });
-
- foreach (RouteNote request in requests)
- {
- await call.RequestStream.WriteAsync(request);
- }
- await call.RequestStream.CompleteAsync();
- await responseReaderTask;
-}
-```
-
-## Try it out!
-
-Build client and server:
-
-Open the solution `examples/csharp/route_guide/RouteGuide.sln` from Visual Studio (or Monodevelop on Linux) and hit "Build".
-
-Run the server, which will listen on port 50052:
-```
-> cd RouteGuideServer/bin/Debug
-> RouteGuideServer.exe
-```
-
-Run the client (in a different terminal):
-```
-> cd RouteGuideClient/bin/Debug
-> RouteGuideClient.exe
-```
-
-You can also run the server and client directly from Visual Studio.
-
-On Linux or Mac, use `mono RouteGuideServer.exe` and `mono RouteGuideClient.exe` to run the server and client.
+[gRPC Basics: C#]:http://www.grpc.io/docs/tutorials/basic/csharp.html
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
index 302a783aa4..d8f3c8f91d 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuide</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>443bbc38</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>256a7eeb</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,13 +37,13 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.7.0.1-beta2\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -77,12 +77,12 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuide/packages.config b/examples/csharp/route_guide/RouteGuide/packages.config
index 8cd2ee758d..22d34981e5 100644
--- a/examples/csharp/route_guide/RouteGuide/packages.config
+++ b/examples/csharp/route_guide/RouteGuide/packages.config
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="Newtonsoft.Json" version="7.0.1-beta2" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideClient/App.config b/examples/csharp/route_guide/RouteGuideClient/App.config
deleted file mode 100644
index 8e15646352..0000000000
--- a/examples/csharp/route_guide/RouteGuideClient/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
- </startup>
-</configuration> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
index cf9e567f5e..f08f0ef43a 100644
--- a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
+++ b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>77622de6</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>d40daa42</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -39,9 +39,13 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -59,7 +63,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@@ -77,12 +80,12 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideClient/packages.config b/examples/csharp/route_guide/RouteGuideClient/packages.config
index 1273624cbd..22d34981e5 100644
--- a/examples/csharp/route_guide/RouteGuideClient/packages.config
+++ b/examples/csharp/route_guide/RouteGuideClient/packages.config
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/App.config b/examples/csharp/route_guide/RouteGuideServer/App.config
deleted file mode 100644
index 8e15646352..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
- </startup>
-</configuration> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
index 55e1331c46..f22b4e5653 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>568005e2</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>e44ce7bb</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -39,9 +39,13 @@
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -60,7 +64,6 @@
<Compile Include="RouteGuideImpl.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@@ -78,12 +81,12 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.1\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config
index 1273624cbd..22d34981e5 100644
--- a/examples/csharp/route_guide/RouteGuideServer/packages.config
+++ b/examples/csharp/route_guide/RouteGuideServer/packages.config
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
- <package id="Grpc" version="0.7.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc" version="0.7.1" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.1" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.1" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/node/README.md b/examples/node/README.md
index 045fe51ede..df681e85dd 100644
--- a/examples/node/README.md
+++ b/examples/node/README.md
@@ -5,21 +5,11 @@ PREREQUISITES
-------------
- `node`: This requires Node 10.x or greater.
-- [homebrew][] on Mac OS X, [linuxbrew][] on Linux. These simplify the installation of the gRPC C core.
+- [homebrew][] on Mac OS X. This simplifies the installation of the gRPC C core.
INSTALL
-------
- - On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][]. Run the following command to install gRPC Node.js.
-
- ```sh
- $ curl -fsSL https://goo.gl/getgrpc | bash -s nodejs
- ```
- This will download and run the [gRPC install script][], then install the latest version of gRPC Nodejs npm package.
- - Clone this repository
-
- ```sh
- $ git clone https://github.com/grpc/grpc.git
- ```
+ - [Install gRPC Node][]
- Install this package's dependencies
@@ -55,6 +45,5 @@ TUTORIAL
You can find a more detailed tutorial in [gRPC Basics: Node.js][]
[homebrew]:http://brew.sh
-[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
-[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
-[gRPC Basics: Node.js]:https://github.com/grpc/grpc/blob/master/examples/node/route_guide/README.md
+[Install gRPC Node]:../../src/node
+[gRPC Basics: Node.js]:http://www.grpc.io/docs/tutorials/basic/node.html
diff --git a/examples/node/route_guide/README.md b/examples/node/route_guide/README.md
index 1048606509..22bcf78986 100644
--- a/examples/node/route_guide/README.md
+++ b/examples/node/route_guide/README.md
@@ -1,363 +1,5 @@
-#gRPC Basics: Node.js
+#gRPC Basics: Node.js sample code
-This tutorial provides a basic Node.js programmer's introduction to working with gRPC. By walking through this example you'll learn how to:
+The files in this folder are the samples used in [gRPC Basics: Node.js][], a detailed tutorial for using gRPC in Node.js.
-- Define a service in a .proto file.
-- Use the Node.js gRPC API to write a simple client and server for your service.
-
-It assumes that you have read the [Getting started](https://github.com/grpc/grpc/tree/master/examples) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto3 version of the protocol buffers language, which is currently in alpha release:you can find out more in the [proto3 language guide](https://developers.google.com/protocol-buffers/docs/proto3) and see the [release notes](https://github.com/google/protobuf/releases) for the new version in the protocol buffers Github repository.
-
-This isn't a comprehensive guide to using gRPC in Node.js: more reference documentation is coming soon.
-
-## Why use gRPC?
-
-Our example is a simple route mapping application that lets clients get information about features on their route, create a summary of their route, and exchange route information such as traffic updates with the server and other clients.
-
-With gRPC we can define our service once in a .proto file and implement clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet - all the complexity of communication between different languages and environments is handled for you by gRPC. We also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL, and easy interface updating.
-
-## Example code and setup
-
-The example code for our tutorial is in [examples/node/route_guide](.). To download the example, clone this repository by running the following command:
-```shell
-$ git clone https://github.com/grpc/grpc.git
-```
-
-Then change your current directory to `examples/node/route_guide`:
-```shell
-$ cd examples/node/route_guide
-```
-
-You also should have the relevant tools installed to generate the server and client interface code - if you don't already, follow the setup instructions in [the Node.js quick start guide](..).
-
-
-## Defining the service
-
-Our first step (as you'll know from [Getting started](https://github.com/grpc/grpc/tree/master/examples)) is to define the gRPC *service* and the method *request* and *response* types using [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in [`examples/protos/route_guide.proto`](../../route_guide.proto).
-
-To define a service, you specify a named `service` in your .proto file:
-
-```protobuf
-service RouteGuide {
- ...
-}
-```
-
-Then you define `rpc` methods inside your service definition, specifying their request and response types. gRPC lets you define four kinds of service method, all of which are used in the `RouteGuide` service:
-
-- A *simple RPC* where the client sends a request to the server using the stub and waits for a response to come back, just like a normal function call.
-```protobuf
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-```
-
-- A *server-side streaming RPC* where the client sends a request to the server and gets a stream to read a sequence of messages back. The client reads from the returned stream until there are no more messages. As you can see in our example, you specify a server-side streaming method by placing the `stream` keyword before the *response* type.
-```protobuf
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-```
-
-- A *client-side streaming RPC* where the client writes a sequence of messages and sends them to the server, again using a provided stream. Once the client has finished writing the messages, it waits for the server to read them all and return its response. You specify a server-side streaming method by placing the `stream` keyword before the *request* type.
-```protobuf
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-```
-
-- A *bidirectional streaming RPC* where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved. You specify this type of method by placing the `stream` keyword before both the request and the response.
-```protobuf
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-```
-
-Our .proto file also contains protocol buffer message type definitions for all the request and response types used in our service methods - for example, here's the `Point` message type:
-```protobuf
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- int32 latitude = 1;
- int32 longitude = 2;
-}
-```
-
-
-## Loading service descriptors from proto files
-
-The Node.js library dynamically generates service descriptors and client stub definitions from `.proto` files loaded at runtime.
-
-To load a `.proto` file, simply `require` the gRPC library, then use its `load()` method:
-
-```node
-var grpc = require('grpc');
-var protoDescriptor = grpc.load(__dirname + '/route_guide.proto');
-// The protoDescriptor object has the full package hierarchy
-var example = protoDescriptor.routeguide;
-```
-
-Once you've done this, the stub constructor is in the `routeguide` namespace (`protoDescriptor.routeguide.RouteGuide`) and the service descriptor (which is used to create a server) is a property of the stub (`protoDescriptor.routeguide.RouteGuide.service`);
-
-<a name="server"></a>
-## Creating the server
-
-First let's look at how we create a `RouteGuide` server. If you're only interested in creating gRPC clients, you can skip this section and go straight to [Creating the client](#client) (though you might find it interesting anyway!).
-
-There are two parts to making our `RouteGuide` service do its job:
-- Implementing the service interface generated from our service definition: doing the actual "work" of our service.
-- Running a gRPC server to listen for requests from clients and return the service responses.
-
-You can find our example `RouteGuide` server in [route_guide_server.js](route_guide_server.js). Let's take a closer look at how it works.
-
-### Implementing RouteGuide
-
-As you can see, our server has a `Server` constructor generated from the `RouteGuide.service` descriptor object
-
-```node
-var Server = grpc.buildServer([routeguide.RouteGuide.service]);
-```
-In this case we're implementing the *asynchronous* version of `RouteGuide`, which provides our default gRPC server behaviour.
-
-The functions in `route_guide_server.js` implement all our service methods. Let's look at the simplest type first, `getFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
-
-```node
-function checkFeature(point) {
- var feature;
- // Check if there is already a feature object for the given point
- for (var i = 0; i < feature_list.length; i++) {
- feature = feature_list[i];
- if (feature.location.latitude === point.latitude &&
- feature.location.longitude === point.longitude) {
- return feature;
- }
- }
- var name = '';
- feature = {
- name: name,
- location: point
- };
- return feature;
-}
-function getFeature(call, callback) {
- callback(null, checkFeature(call.request));
-}
-```
-
-The method is passed a call object for the RPC, which has the `Point` parameter as a property, and a callback to which we can pass our returned `Feature`. In the method body we populate a `Feature` corresponding to the given point and pass it to the callback, with a null first parameter to indicate that there is no error.
-
-Now let's look at something a bit more complicated - a streaming RPC. `listFeatures` is a server-side streaming RPC, so we need to send back multiple `Feature`s to our client.
-
-```node
-function listFeatures(call) {
- var lo = call.request.lo;
- var hi = call.request.hi;
- var left = _.min([lo.longitude, hi.longitude]);
- var right = _.max([lo.longitude, hi.longitude]);
- var top = _.max([lo.latitude, hi.latitude]);
- var bottom = _.min([lo.latitude, hi.latitude]);
- // For each feature, check if it is in the given bounding box
- _.each(feature_list, function(feature) {
- if (feature.name === '') {
- return;
- }
- if (feature.location.longitude >= left &&
- feature.location.longitude <= right &&
- feature.location.latitude >= bottom &&
- feature.location.latitude <= top) {
- call.write(feature);
- }
- });
- call.end();
-}
-```
-
-As you can see, instead of getting the call object and callback in our method parameters, this time we get a `call` object that implements the `Writable` interface. In the method, we create as many `Feature` objects as we need to return, writing them to the `call` using its `write()` method. Finally, we call `call.end()` to indicate that we have sent all messages.
-
-If you look at the client-side streaming method `RecordRoute` you'll see it's quite similar to the unary call, except this time the `call` parameter implements the `Reader` interface. The `call`'s `'data'` event fires every time there is new data, and the `'end'` event fires when all data has been read. Like the unary case, we respond by calling the callback
-
-```node
-call.on('data', function(point) {
- // Process user data
-});
-call.on('end', function() {
- callback(null, result);
-});
-```
-
-Finally, let's look at our bidirectional streaming RPC `RouteChat()`.
-
-```node
-function routeChat(call) {
- call.on('data', function(note) {
- var key = pointKey(note.location);
- /* For each note sent, respond with all previous notes that correspond to
- * the same point */
- if (route_notes.hasOwnProperty(key)) {
- _.each(route_notes[key], function(note) {
- call.write(note);
- });
- } else {
- route_notes[key] = [];
- }
- // Then add the new note to the list
- route_notes[key].push(JSON.parse(JSON.stringify(note)));
- });
- call.on('end', function() {
- call.end();
- });
-}
-```
-
-This time we get a `call` implementing `Duplex` that can be used to read *and* write messages. The syntax for reading and writing here is exactly the same as for our client-streaming and server-streaming methods. Although each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
-
-### Starting the server
-
-Once we've implemented all our methods, we also need to start up a gRPC server so that clients can actually use our service. The following snippet shows how we do this for our `RouteGuide` service:
-
-```node
-function getServer() {
- var server = new grpc.Server();
- server.addProtoService(routeguide.RouteGuide.service, {
- getFeature: getFeature,
- listFeatures: listFeatures,
- recordRoute: recordRoute,
- routeChat: routeChat
- });
- return server;
-}
-var routeServer = getServer();
-routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
-routeServer.start();
-```
-
-As you can see, we build and start our server with the following steps:
-
- 1. Create a `Server` constructor from the `RouteGuide` service descriptor.
- 2. Implement the service methods.
- 3. Create an instance of the server by calling the `Server` constructor with the method implementations.
- 4. Specify the address and port we want to use to listen for client requests using the instance's `bind()` method.
- 5. Call `listen()` on the instance to start the RPC server.
-
-<a name="client"></a>
-## Creating the client
-
-In this section, we'll look at creating a Node.js client for our `RouteGuide` service. You can see our complete example client code in [route_guide_client.js](route_guide_client.js).
-
-### Creating a stub
-
-To call service methods, we first need to create a *stub*. To do this, we just need to call the RouteGuide stub constructor, specifying the server address and port.
-
-```node
-var client = new routeguide.RouteGuide('localhost:50051',
- grpc.Credentials.createInsecure());
-```
-
-### Calling service methods
-
-Now let's look at how we call our service methods. Note that all of these methods are asynchronous: they use either events or callbacks to retrieve results.
-
-#### Simple RPC
-
-Calling the simple RPC `GetFeature` is nearly as straightforward as calling a local asynchronous method.
-
-```node
-var point = {latitude: 409146138, longitude: -746188906};
-stub.getFeature(point, function(err, feature) {
- if (err) {
- // process error
- } else {
- // process feature
- }
-});
-```
-
-As you can see, we create and populate a request object. Finally, we call the method on the stub, passing it the request and callback. If there is no error, then we can read the response information from the server from our response object.
-
-```node
- console.log('Found feature called "' + feature.name + '" at ' +
- feature.location.latitude/COORD_FACTOR + ', ' +
- feature.location.longitude/COORD_FACTOR);
-```
-
-#### Streaming RPCs
-
-Now let's look at our streaming methods. If you've already read [Creating the server](#server) some of this may look very familiar - streaming RPCs are implemented in a similar way on both sides. Here's where we call the server-side streaming method `ListFeatures`, which returns a stream of geographical `Feature`s:
-
-```node
-var call = client.listFeatures(rectangle);
- call.on('data', function(feature) {
- console.log('Found feature called "' + feature.name + '" at ' +
- feature.location.latitude/COORD_FACTOR + ', ' +
- feature.location.longitude/COORD_FACTOR);
- });
- call.on('end', function() {
- // The server has finished sending
- });
- call.on('status', function(status) {
- // process status
- });
-```
-
-Instead of passing the method a request and callback, we pass it a request and get a `Readable` stream object back. The client can use the `Readable`'s `'data'` event to read the server's responses. This event fires with each `Feature` message object until there are no more messages: the `'end'` event indicates that the call is done. Finally, the status event fires when the server sends the status.
-
-The client-side streaming method `RecordRoute` is similar, except there we pass the method a callback and get back a `Writable`.
-
-```node
- var call = client.recordRoute(function(error, stats) {
- if (error) {
- callback(error);
- }
- console.log('Finished trip with', stats.point_count, 'points');
- console.log('Passed', stats.feature_count, 'features');
- console.log('Travelled', stats.distance, 'meters');
- console.log('It took', stats.elapsed_time, 'seconds');
- });
- function pointSender(lat, lng) {
- return function(callback) {
- console.log('Visiting point ' + lat/COORD_FACTOR + ', ' +
- lng/COORD_FACTOR);
- call.write({
- latitude: lat,
- longitude: lng
- });
- _.delay(callback, _.random(500, 1500));
- };
- }
- var point_senders = [];
- for (var i = 0; i < num_points; i++) {
- var rand_point = feature_list[_.random(0, feature_list.length - 1)];
- point_senders[i] = pointSender(rand_point.location.latitude,
- rand_point.location.longitude);
- }
- async.series(point_senders, function() {
- call.end();
- });
-```
-
-Once we've finished writing our client's requests to the stream using `write()`, we need to call `end()` on the stream to let gRPC know that we've finished writing. If the status is `OK`, the `stats` object will be populated with the server's response.
-
-Finally, let's look at our bidirectional streaming RPC `routeChat()`. In this case, we just pass a context to the method and get back a `Duplex` stream object, which we can use to both write and read messages.
-
-```node
-var call = client.routeChat();
-```
-
-The syntax for reading and writing here is exactly the same as for our client-streaming and server-streaming methods. Although each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
-
-## Try it out!
-
-Build client and server:
-```shell
-$ npm install
-```
-Run the server, which will listen on port 50051:
-```shell
-$ node ./route_guide_server.js --db_path=route_guide_db.json
-```
-Run the client (in a different terminal):
-```shell
-$ node ./route_guide_client.js --db_path=route_guide_db.json
-```
+[gRPC Basics: Node.js]:http://www.grpc.io/docs/tutorials/basic/node.html
diff --git a/examples/php/README.md b/examples/php/README.md
index 5c327f10fa..a4ee8e698b 100644
--- a/examples/php/README.md
+++ b/examples/php/README.md
@@ -56,9 +56,10 @@ some Protocol Buffer 2.0 syntax. There is no proto3 support for PHP yet.
TUTORIAL
--------
-Coming soon
+You can find a more detailed tutorial in [gRPC Basics: PHP][]
[homebrew]:http://brew.sh
[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
[Node]:https://github.com/grpc/grpc/tree/master/examples/node
+[gRPC Basics: PHP]:http://www.grpc.io/docs/tutorials/basic/php.html
diff --git a/examples/php/composer.json b/examples/php/composer.json
index f0ce3a2aff..9f44f0b186 100644
--- a/examples/php/composer.json
+++ b/examples/php/composer.json
@@ -12,6 +12,6 @@
"php": ">=5.5.0",
"datto/protobuf-php": "dev-master",
"google/auth": "dev-master",
- "grpc/grpc": "dev-master"
+ "grpc/grpc": "dev-release-0_11"
}
}
diff --git a/examples/php/greeter_client.php b/examples/php/greeter_client.php
index 8ae19ae46c..e5e4c2651e 100644
--- a/examples/php/greeter_client.php
+++ b/examples/php/greeter_client.php
@@ -36,8 +36,7 @@ require dirname(__FILE__) . '/vendor/autoload.php';
require dirname(__FILE__) . '/helloworld.php';
function greet($name) {
- $client = new helloworld\GreeterClient(
- new Grpc\BaseStub('localhost:50051', []));
+ $client = new helloworld\GreeterClient('localhost:50051', []);
$request = new helloworld\HelloRequest();
$request->setName($name);
list($reply, $status) = $client->SayHello($request)->wait();
diff --git a/examples/php/helloworld.php b/examples/php/helloworld.php
index 22da3d3970..50923e6fcd 100644
--- a/examples/php/helloworld.php
+++ b/examples/php/helloworld.php
@@ -1,7 +1,7 @@
<?php
// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
// Source: helloworld.proto
-// Date: 2015-05-29 21:39:19
+// Date: 2015-09-24 20:40:14
namespace helloworld {
@@ -143,18 +143,16 @@ namespace helloworld {
namespace helloworld {
- class GreeterClient{
+ class GreeterClient extends \Grpc\BaseStub {
- private $rpc_impl;
-
- public function __construct($rpc_impl) {
- $this->rpc_impl = $rpc_impl;
+ public function __construct($hostname, $opts) {
+ parent::__construct($hostname, $opts);
}
/**
* @param helloworld\HelloRequest $input
*/
- public function SayHello(\helloworld\HelloRequest $argument, $metadata = array()) {
- return $this->rpc_impl->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata);
+ public function SayHello(\helloworld\HelloRequest $argument, $metadata = array(), $options = array()) {
+ return $this->_simpleRequest('/helloworld.Greeter/SayHello', $argument, '\helloworld\HelloReply::deserialize', $metadata, $options);
}
}
}
diff --git a/examples/php/route_guide/README.md b/examples/php/route_guide/README.md
index 00610ffb09..4e74a79f13 100644
--- a/examples/php/route_guide/README.md
+++ b/examples/php/route_guide/README.md
@@ -1,262 +1,6 @@
-#gRPC Basics: PHP
+#gRPC Basics: PHP sample code
-This tutorial provides a basic PHP programmer's introduction to working with gRPC. By walking through this example you'll learn how to:
+The files in this folder are the samples used in [gRPC Basics: PHP][],
+a detailed tutorial for using gRPC in Ruby.
-- Define a service in a .proto file.
-- Generate client code using the protocol buffer compiler.
-- Use the PHP gRPC API to write a simple client for your service.
-
-It assumes a passing familiarity with [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto2 version of the protocol buffers language.
-
-Also note that currently you can only create clients in PHP for gRPC services - you can find out how to create gRPC servers in our other tutorials, e.g. [Node.js](../node/route_guide).
-
-This isn't a comprehensive guide to using gRPC in PHP: more reference documentation is coming soon.
-
-- [Why use gRPC?](#why-grpc)
-- [Example code and setup](#setup)
-- [Try it out!](#try)
-- [Defining the service](#proto)
-- [Generating client code](#protoc)
-- [Creating the client](#client)
-
-
-<a name="why-grpc"></a>
-## Why use gRPC?
-
-With gRPC you can define your service once in a .proto file and implement clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet - all the complexity of communication between different languages and environments is handled for you by gRPC. You also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL, and easy interface updating.
-
-
-<a name="setup"></a>
-## Example code and setup
-
-The example code for our tutorial is in [examples/php/route_guide](.). To download the example, clone this repository by running the following command:
-```shell
-$ git clone https://github.com/grpc/grpc.git
-```
-
-Then change your current directory to `examples/php/route_guide`:
-```shell
-$ cd examples/php/route_guide
-```
-
-Our example is a simple route mapping application that lets clients get information about features on their route, create a summary of their route, and exchange route information such as traffic updates with the server and other clients.
-
-You also should have the relevant tools installed to generate the client interface code (and a server in another language, for testing). You can obtain the latter by following [these setup instructions](https://github.com/grpc/homebrew-grpc).
-
-
-<a name="try"></a>
-## Try it out!
-
-To try the sample app, we need a gRPC server running locally. Let's compile and run, for example, the Node.js server in this repository:
-
-```shell
-$ cd ../../node
-$ npm install
-$ cd route_guide
-$ nodejs ./route_guide_server.js --db_path=route_guide_db.json
-```
-
-Run the PHP client (in a different terminal):
-
-```shell
-$ ./run_route_guide_client.sh
-```
-
-The next sections guide you step-by-step through how this proto service is defined, how to generate a client library from it, and how to create a client stub that uses that library.
-
-
-<a name="proto"></a>
-## Defining the service
-
-First let's look at how the service we're using is defined. A gRPC *service* and its method *request* and *response* types using [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file for our example in [`route_guide.proto`](route_guide.proto).
-
-To define a service, you specify a named `service` in your .proto file:
-
-```protobuf
-service RouteGuide {
- ...
-}
-```
-
-Then you define `rpc` methods inside your service definition, specifying their request and response types. Protocol buffers let you define four kinds of service method, all of which are used in the `RouteGuide` service:
-
-- A *simple RPC* where the client sends a request to the server and receives a response later, just like a normal remote procedure call.
-```protobuf
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-```
-
-- A *response-streaming RPC* where the client sends a request to the server and gets back a stream of response messages. You specify a response-streaming method by placing the `stream` keyword before the *response* type.
-```protobuf
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-```
-
-- A *request-streaming RPC* where the client sends a sequence of messages to the server. Once the client has finished writing the messages, it waits for the server to read them all and return its response. You specify a request-streaming method by placing the `stream` keyword before the *request* type.
-```protobuf
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-```
-
-- A *bidirectional streaming RPC* where both sides send a sequence of messages to the other. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved. You specify this type of method by placing the `stream` keyword before both the request and the response.
-```protobuf
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-```
-
-Our .proto file also contains protocol buffer message type definitions for all the request and response types used in our service methods - for example, here's the `Point` message type:
-```protobuf
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- int32 latitude = 1;
- int32 longitude = 2;
-}
-```
-
-
-<a name="protoc"></a>
-## Generating client code
-
-The PHP client stub implementation of the proto files can be generated by the [`protoc-gen-php`](https://github.com/datto/protobuf-php) tool. To install the tool:
-
-```sh
-$ cd examples/php
-$ php composer.phar install
-$ cd vendor/datto/protobuf-php
-$ gem install rake ronn
-$ rake pear:package version=1.0
-$ sudo pear install Protobuf-1.0.tgz
-```
-
-To generate the client stub implementation .php file:
-
-```sh
-$ cd php/route_guide
-$ protoc-gen-php -i . -o . ./route_guide.proto
-```
-
-A `route_guide.php` file will be generated in the `php/route_guide` directory. You do not need to modify the file.
-
-To load the generated client stub file, simply `require` it in your PHP application:
-
-```php
-require dirname(__FILE__) . '/route_guide.php';
-```
-
-The file contains:
-- All the protocol buffer code to populate, serialize, and retrieve our request and response message types.
-- A class called `routeguide\RouteGuideClient` that lets clients call the methods defined in the `RouteGuide` service.
-
-
-<a name="client"></a>
-## Creating the client
-
-In this section, we'll look at creating a PHP client for our `RouteGuide` service. You can see our complete example client code in [route_guide_client.php](route_guide_client.php).
-
-### Constructing a client object
-
-To call service methods, we first need to create a client object, an instance of the generated `RouteGuideClient` class. The constructor of the class expects the server address and port we want to connect to:
-
-```php
-$client = new routeguide\RouteGuideClient(new Grpc\BaseStub('localhost:50051', []));
-```
-
-### Calling service methods
-
-Now let's look at how we call our service methods.
-
-#### Simple RPC
-
-Calling the simple RPC `GetFeature` is nearly as straightforward as calling a local asynchronous method.
-
-```php
- $point = new routeguide\Point();
- $point->setLatitude(409146138);
- $point->setLongitude(-746188906);
- list($feature, $status) = $client->GetFeature($point)->wait();
-```
-
-As you can see, we create and populate a request object, i.e. an `routeguide\Point` object. Then, we call the method on the stub, passing it the request object. If there is no error, then we can read the response information from the server from our response object, i.e. an `routeguide\Feature` object.
-
-```php
- print sprintf("Found %s \n at %f, %f\n", $feature->getName(),
- $feature->getLocation()->getLatitude() / COORD_FACTOR,
- $feature->getLocation()->getLongitude() / COORD_FACTOR);
-```
-
-#### Streaming RPCs
-
-Now let's look at our streaming methods. Here's where we call the server-side streaming method `ListFeatures`, which returns a stream of geographical `Feature`s:
-
-```php
- $lo_point = new routeguide\Point();
- $hi_point = new routeguide\Point();
-
- $lo_point->setLatitude(400000000);
- $lo_point->setLongitude(-750000000);
- $hi_point->setLatitude(420000000);
- $hi_point->setLongitude(-730000000);
-
- $rectangle = new routeguide\Rectangle();
- $rectangle->setLo($lo_point);
- $rectangle->setHi($hi_point);
-
- $call = $client->ListFeatures($rectangle);
- // an iterator over the server streaming responses
- $features = $call->responses();
- foreach ($features as $feature) {
- // process each feature
- } // the loop will end when the server indicates there is no more responses to be sent.
-```
-
-The `$call->responses()` method call returns an iterator. When the server sends a response, a `$feature` object will be returned in the `foreach` loop, until the server indiciates that there will be no more responses to be sent.
-
-The client-side streaming method `RecordRoute` is similar, except there we pass the method an iterator and get back a `routeguide\RouteSummary`.
-
-```php
- $points_iter = function($db) {
- for ($i = 0; $i < $num_points; $i++) {
- $point = new routeguide\Point();
- $point->setLatitude($lat);
- $point->setLongitude($long);
- yield $point;
- }
- };
- // $points_iter is an iterator simulating client streaming
- list($route_summary, $status) =
- $client->RecordRoute($points_iter($db))->wait();
-```
-
-Finally, let's look at our bidirectional streaming RPC `routeChat()`. In this case, we just pass a context to the method and get back a `BidiStreamingCall` stream object, which we can use to both write and read messages.
-
-```php
-$call = $client->RouteChat();
-```
-
-To write messages from the client:
-
-```php
- foreach ($notes as $n) {
- $route_note = new routerguide\RouteNote();
- $call->write($route_note);
- }
- $call->writesDone();
-```
-
-To read messages from the server:
-
-```php
- while ($route_note_reply = $call->read()) {
- // process $route_note_reply
- }
-```
-
-Each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
+[gRPC Basics: PHP]:http://www.grpc.io/docs/tutorials/basic/php.html
diff --git a/examples/php/route_guide/route_guide.php b/examples/php/route_guide/route_guide.php
index 76086f9772..0de319890d 100644
--- a/examples/php/route_guide/route_guide.php
+++ b/examples/php/route_guide/route_guide.php
@@ -1,7 +1,7 @@
<?php
// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
// Source: route_guide.proto
-// Date: 2015-08-31 21:11:45
+// Date: 2015-09-24 21:21:51
namespace routeguide {
diff --git a/examples/php/route_guide/route_guide_client.php b/examples/php/route_guide/route_guide_client.php
index d21a080995..3cd1df7254 100644
--- a/examples/php/route_guide/route_guide_client.php
+++ b/examples/php/route_guide/route_guide_client.php
@@ -37,8 +37,7 @@ require dirname(__FILE__) . '/route_guide.php';
define('COORD_FACTOR', 1e7);
-$client = new routeguide\RouteGuideClient(
- new Grpc\BaseStub('localhost:50051', []));
+$client = new routeguide\RouteGuideClient('localhost:50051', []);
function printFeature($feature) {
$name = $feature->getName();
@@ -96,6 +95,7 @@ function runListFeatures() {
$rectangle->setLo($lo_point);
$rectangle->setHi($hi_point);
+ // start the server streaming call
$call = $client->ListFeatures($rectangle);
// an iterator over the server streaming responses
$features = $call->responses();
@@ -113,28 +113,27 @@ function runRecordRoute() {
print "Running RecordRoute...\n";
global $client, $argv;
+ // start the client streaming call
+ $call = $client->RecordRoute();
+
$db = json_decode(file_get_contents($argv[1]), true);
- $points_iter = function($db) {
- $num_points_in_db = count($db);
- $num_points = 10;
- for ($i = 0; $i < $num_points; $i++) {
- $point = new routeguide\Point();
- $index = rand(0, $num_points_in_db - 1);
- $lat = $db[$index]['location']['latitude'];
- $long = $db[$index]['location']['longitude'];
- $feature_name = $db[$index]['name'];
- $point->setLatitude($lat);
- $point->setLongitude($long);
- print sprintf("Visiting point %f, %f,\n with feature name: %s\n",
- $lat / COORD_FACTOR, $long / COORD_FACTOR,
- $feature_name ? $feature_name : '<empty>');
- usleep(rand(300000, 800000));
- yield $point;
- }
- };
- // $points_iter is an iterator simulating client streaming
- list($route_summary, $status) =
- $client->RecordRoute($points_iter($db))->wait();
+ $num_points_in_db = count($db);
+ $num_points = 10;
+ for ($i = 0; $i < $num_points; $i++) {
+ $point = new routeguide\Point();
+ $index = rand(0, $num_points_in_db - 1);
+ $lat = $db[$index]['location']['latitude'];
+ $long = $db[$index]['location']['longitude'];
+ $feature_name = $db[$index]['name'];
+ $point->setLatitude($lat);
+ $point->setLongitude($long);
+ print sprintf("Visiting point %f, %f,\n with feature name: %s\n",
+ $lat / COORD_FACTOR, $long / COORD_FACTOR,
+ $feature_name ? $feature_name : '<empty>');
+ usleep(rand(300000, 800000));
+ $call->write($point);
+ }
+ list($route_summary, $status) = $call->wait();
print sprintf("Finished trip with %d points\nPassed %d features\n".
"Travelled %d meters\nIt took %d seconds\n",
$route_summary->getPointCount(),
diff --git a/examples/php/route_guide/run_route_guide_client.sh b/examples/php/route_guide/run_route_guide_client.sh
index e5ca07796b..90ecc6270b 100755
--- a/examples/php/route_guide/run_route_guide_client.sh
+++ b/examples/php/route_guide/run_route_guide_client.sh
@@ -30,7 +30,5 @@
set -e
cd $(dirname $0)
-command -v brew >/dev/null 2>&1 && \
- extension_dir="-d extension_dir="`brew --prefix`/opt/grpc-php
-php $extension_dir -d extension=grpc.so \
+php $extension_dir -d extension=grpc.so -d max_execution_time=300 \
route_guide_client.php ../../node/route_guide/route_guide_db.json
diff --git a/examples/php/run_greeter_client.sh b/examples/php/run_greeter_client.sh
index 2906de9af8..1a6e9ee101 100755
--- a/examples/php/run_greeter_client.sh
+++ b/examples/php/run_greeter_client.sh
@@ -30,6 +30,5 @@
set -e
cd $(dirname $0)
-command -v brew >/dev/null 2>&1 && \
- extension_dir="-d extension_dir="`brew --prefix`/opt/grpc-php
-php $extension_dir -d extension=grpc.so greeter_client.php $1
+php $extension_dir -d extension=grpc.so -d max_execution_time=300 \
+ greeter_client.php $1
diff --git a/examples/ruby/Gemfile b/examples/ruby/Gemfile
index 65d3f0ad4a..e75f0f6137 100644
--- a/examples/ruby/Gemfile
+++ b/examples/ruby/Gemfile
@@ -3,4 +3,4 @@
source 'https://rubygems.org/'
-gem 'grpc', :git => 'https://github.com/grpc/grpc.git', :submodules => true, glob: 'src/ruby/*.gemspec'
+gemspec
diff --git a/examples/ruby/README.md b/examples/ruby/README.md
index 36f3527006..98dee13740 100644
--- a/examples/ruby/README.md
+++ b/examples/ruby/README.md
@@ -25,8 +25,8 @@ RVM is also useful if you don't have the necessary privileges to update your sys
INSTALL
-------
+- [Install gRPC Ruby][]
-- Clone this repository
- Use bundler to install the example package's dependencies
```sh
@@ -35,7 +35,7 @@ INSTALL
$ bundle install
```
-Try it!
+Try it!
-------
- Run the server
@@ -55,7 +55,9 @@ Try it!
Tutorial
--------
-You can find a more detailed tutorial in [gRPC Basics: Ruby](route_guide/README.md)
+You can find a more detailed tutorial in [gRPC Basics: Ruby][]
[helloworld.proto]:../protos/helloworld.proto
[RVM]:https://www.rvm.io/
+[Install gRPC ruby]:../../src/ruby#installation
+[gRPC Basics: Ruby]:http://www.grpc.io/docs/tutorials/basic/ruby.html
diff --git a/examples/ruby/greeter_server.rb b/examples/ruby/greeter_server.rb
index d4f9cf7d0f..622513d380 100755
--- a/examples/ruby/greeter_server.rb
+++ b/examples/ruby/greeter_server.rb
@@ -52,9 +52,9 @@ end
# server port.
def main
s = GRPC::RpcServer.new
- s.add_http2_port('0.0.0.0:50051')
+ s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)
s.handle(GreeterServer)
- s.run
+ s.run_till_terminated
end
main
diff --git a/examples/ruby/grpc-demo.gemspec b/examples/ruby/grpc-demo.gemspec
index 2cc1eb8f41..b1dfdae6ab 100644
--- a/examples/ruby/grpc-demo.gemspec
+++ b/examples/ruby/grpc-demo.gemspec
@@ -3,7 +3,7 @@
Gem::Specification.new do |s|
s.name = 'grpc-demo'
- s.version = '0.5.0'
+ s.version = '0.11.0'
s.authors = ['gRPC Authors']
s.email = 'temiola@google.com'
s.homepage = 'https://github.com/grpc/grpc'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']
s.platform = Gem::Platform::RUBY
- s.add_dependency 'grpc', '~> 0.6'
+ s.add_dependency 'grpc', '~> 0.11'
s.add_development_dependency 'bundler', '~> 1.7'
end
diff --git a/examples/ruby/lib/route_guide.rb b/examples/ruby/lib/route_guide.rb
index 98bac8395c..424395c4f5 100644
--- a/examples/ruby/lib/route_guide.rb
+++ b/examples/ruby/lib/route_guide.rb
@@ -4,23 +4,23 @@
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
- add_message "examples.Point" do
+ add_message "routeguide.Point" do
optional :latitude, :int32, 1
optional :longitude, :int32, 2
end
- add_message "examples.Rectangle" do
- optional :lo, :message, 1, "examples.Point"
- optional :hi, :message, 2, "examples.Point"
+ add_message "routeguide.Rectangle" do
+ optional :lo, :message, 1, "routeguide.Point"
+ optional :hi, :message, 2, "routeguide.Point"
end
- add_message "examples.Feature" do
+ add_message "routeguide.Feature" do
optional :name, :string, 1
- optional :location, :message, 2, "examples.Point"
+ optional :location, :message, 2, "routeguide.Point"
end
- add_message "examples.RouteNote" do
- optional :location, :message, 1, "examples.Point"
+ add_message "routeguide.RouteNote" do
+ optional :location, :message, 1, "routeguide.Point"
optional :message, :string, 2
end
- add_message "examples.RouteSummary" do
+ add_message "routeguide.RouteSummary" do
optional :point_count, :int32, 1
optional :feature_count, :int32, 2
optional :distance, :int32, 3
@@ -28,10 +28,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
end
end
-module Examples
- Point = Google::Protobuf::DescriptorPool.generated_pool.lookup("examples.Point").msgclass
- Rectangle = Google::Protobuf::DescriptorPool.generated_pool.lookup("examples.Rectangle").msgclass
- Feature = Google::Protobuf::DescriptorPool.generated_pool.lookup("examples.Feature").msgclass
- RouteNote = Google::Protobuf::DescriptorPool.generated_pool.lookup("examples.RouteNote").msgclass
- RouteSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("examples.RouteSummary").msgclass
+module Routeguide
+ Point = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Point").msgclass
+ Rectangle = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Rectangle").msgclass
+ Feature = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Feature").msgclass
+ RouteNote = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteNote").msgclass
+ RouteSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteSummary").msgclass
end
diff --git a/examples/ruby/lib/route_guide_services.rb b/examples/ruby/lib/route_guide_services.rb
index 6e07653c42..082daef754 100644
--- a/examples/ruby/lib/route_guide_services.rb
+++ b/examples/ruby/lib/route_guide_services.rb
@@ -1,10 +1,10 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
-# Source: route_guide.proto for package 'examples'
+# Source: route_guide.proto for package 'routeguide'
require 'grpc'
require 'route_guide'
-module Examples
+module Routeguide
module RouteGuide
# TODO: add proto service documentation here
@@ -14,7 +14,7 @@ module Examples
self.marshal_class_method = :encode
self.unmarshal_class_method = :decode
- self.service_name = 'examples.RouteGuide'
+ self.service_name = 'routeguide.RouteGuide'
rpc :GetFeature, Point, Feature
rpc :ListFeatures, Rectangle, stream(Feature)
diff --git a/examples/ruby/route_guide/README.md b/examples/ruby/route_guide/README.md
index 77e93d8bd4..3c353d1d97 100644
--- a/examples/ruby/route_guide/README.md
+++ b/examples/ruby/route_guide/README.md
@@ -1,285 +1,6 @@
-#gRPC Basics: Ruby
+#gRPC Basics: Ruby sample code
-This tutorial provides a basic Ruby programmer's introduction to working with gRPC. By walking through this example you'll learn how to:
-
-- Define a service in a .proto file.
-- Generate server and client code using the protocol buffer compiler.
-- Use the Ruby gRPC API to write a simple client and server for your service.
-
-It assumes that you have read the [Getting started](https://github.com/grpc/grpc/tree/master/examples) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto3 version of the protocol buffers language, which is currently in alpha release:you can find out more in the [proto3 language guide](https://developers.google.com/protocol-buffers/docs/proto3) and see the [release notes](https://github.com/google/protobuf/releases) for the new version in the protocol buffers Github repository.
-
-This isn't a comprehensive guide to using gRPC in Ruby: more reference documentation is coming soon.
-
-## Why use gRPC?
-
-Our example is a simple route mapping application that lets clients get information about features on their route, create a summary of their route, and exchange route information such as traffic updates with the server and other clients.
-
-With gRPC we can define our service once in a .proto file and implement clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet - all the complexity of communication between different languages and environments is handled for you by gRPC. We also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL, and easy interface updating.
-
-## Example code and setup
-
-The example code for our tutorial is in [examples/ruby/route_guide](.). To download the example, clone this repository by running the following command:
-```shell
-$ git clone https://github.com/grpc/grpc.git
-```
-
-Then change your current directory to `examples/ruby/route_guide`:
-```shell
-$ cd examples/ruby/route_guide
-```
-
-You also should have the relevant tools installed to generate the server and client interface code - if you don't already, follow the setup instructions in [the Ruby quick start guide](..).
-
-
-## Defining the service
-
-Our first step (as you'll know from [Getting started](https://github.com/grpc/grpc/tree/master/examples)) is to define the gRPC *service* and the method *request* and *response* types using [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in [`examples/protos/route_guide.proto`](../../route_guide.proto).
-
-To define a service, you specify a named `service` in your .proto file:
-
-```protobuf
-service RouteGuide {
- ...
-}
-```
-
-Then you define `rpc` methods inside your service definition, specifying their request and response types. gRPC lets you define four kinds of service method, all of which are used in the `RouteGuide` service:
-
-- A *simple RPC* where the client sends a request to the server using the stub and waits for a response to come back, just like a normal function call.
-```protobuf
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-```
-
-- A *server-side streaming RPC* where the client sends a request to the server and gets a stream to read a sequence of messages back. The client reads from the returned stream until there are no more messages. As you can see in our example, you specify a server-side streaming method by placing the `stream` keyword before the *response* type.
-```protobuf
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-```
-
-- A *client-side streaming RPC* where the client writes a sequence of messages and sends them to the server, again using a provided stream. Once the client has finished writing the messages, it waits for the server to read them all and return its response. You specify a server-side streaming method by placing the `stream` keyword before the *request* type.
-```protobuf
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-```
-
-- A *bidirectional streaming RPC* where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved. You specify this type of method by placing the `stream` keyword before both the request and the response.
-```protobuf
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-```
-
-Our .proto file also contains protocol buffer message type definitions for all the request and response types used in our service methods - for example, here's the `Point` message type:
-```protobuf
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- int32 latitude = 1;
- int32 longitude = 2;
-}
-```
-
-
-## Generating client and server code
-
-Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler `protoc` with a special gRPC Ruby plugin.
-
-If you want to run this yourself, make sure you've installed protoc and followed the gRPC Ruby plugin [installation instructions](https://github.com/grpc/grpc/blob/master/INSTALL) first):
-
-Once that's done, the following command can be used to generate the ruby code.
-
-```shell
-$ protoc -I ../../protos --ruby_out=lib --grpc_out=lib --plugin=protoc-gen-grpc=`which grpc_ruby_plugin` ../../protos/route_guide.proto
-```
-
-Running this command regenerates the following files in the lib directory:
-- `lib/route_guide.pb` defines a module `Examples::RouteGuide`
- - This contain all the protocol buffer code to populate, serialize, and retrieve our request and response message types
-- `lib/route_guide_services.pb`, extends `Examples::RouteGuide` with stub and service classes
- - a class `Service` for use as a base class when defining RouteGuide service implementations
- - a class `Stub` that can be used to access remote RouteGuide instances
-
-
-<a name="server"></a>
-## Creating the server
-
-First let's look at how we create a `RouteGuide` server. If you're only interested in creating gRPC clients, you can skip this section and go straight to [Creating the client](#client) (though you might find it interesting anyway!).
-
-There are two parts to making our `RouteGuide` service do its job:
-- Implementing the service interface generated from our service definition: doing the actual "work" of our service.
-- Running a gRPC server to listen for requests from clients and return the service responses.
-
-You can find our example `RouteGuide` server in [route_guide_server.rb](route_guide_server.rb). Let's take a closer look at how it works.
-
-### Implementing RouteGuide
-
-As you can see, our server has a `ServerImpl` class that extends the generated `RouteGuide::Service`:
-
-```ruby
-# ServerImpl provides an implementation of the RouteGuide service.
-class ServerImpl < RouteGuide::Service
-```
-
-`ServerImpl` implements all our service methods. Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
-
-```ruby
- def get_feature(point, _call)
- name = @feature_db[{
- 'longitude' => point.longitude,
- 'latitude' => point.latitude }] || ''
- Feature.new(location: point, name: name)
- end
-```
-
-The method is passed a _call for the RPC, the client's `Point` protocol buffer request, and returns a `Feature` protocol buffer. In the method we create the `Feature` with the appropriate information, and then `return` it.
-
-Now let's look at something a bit more complicated - a streaming RPC. `ListFeatures` is a server-side streaming RPC, so we need to send back multiple `Feature`s to our client.
-
-```ruby
-# in ServerImpl
-
- def list_features(rectangle, _call)
- RectangleEnum.new(@feature_db, rectangle).each
- end
-```
-
-As you can see, here the request object is a `Rectangle` in which our client wants to find `Feature`s, but instead of returning a simple response we need to return an [Enumerator](http://ruby-doc.org//core-2.2.0/Enumerator.html) that yields the responses. In the method, we use a helper class `RectangleEnum`, to act as an Enumerator implementation.
-
-Similarly, the client-side streaming method `record_route` uses an [Enumerable](http://ruby-doc.org//core-2.2.0/Enumerable.html), but here it's obtained from the call object, which we've ignored in the earlier examples. `call.each_remote_read` yields each message sent by the client in turn.
-
-```ruby
- call.each_remote_read do |point|
- ...
- end
-```
-Finally, let's look at our bidirectional streaming RPC `route_chat`.
-
-```ruby
- def route_chat(notes)
- q = EnumeratorQueue.new(self)
- t = Thread.new do
- begin
- notes.each do |n|
- ...
- end
- end
- q = EnumeratorQueue.new(self)
- ...
- return q.each_item
- end
-```
-
-Here the method receives an [Enumerable](http://ruby-doc.org//core-2.2.0/Enumerable.html), but also returns an [Enumerator](http://ruby-doc.org//core-2.2.0/Enumerator.html) that yields the responses. The implementation demonstrates how to set these up so that the requests and responses can be handled concurrently. Although each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
-
-### Starting the server
-
-Once we've implemented all our methods, we also need to start up a gRPC server so that clients can actually use our service. The following snippet shows how we do this for our `RouteGuide` service:
-
-```ruby
- s = GRPC::RpcServer.new
- s.add_http2_port(port)
- logger.info("... running insecurely on #{port}")
- s.handle(ServerImpl.new(feature_db))
- s.run
-```
-As you can see, we build and start our server using a `GRPC::RpcServer`. To do this, we:
-
-1. Create an instance of our service implementation class `ServerImpl`.
-2. Specify the address and port we want to use to listen for client requests using the builder's `add_http2_port` method.
-3. Register our service implementation with the `GRPC::RpcServer`.
-4. Call `run` on the`GRPC::RpcServer` to create and start an RPC server for our service.
-
-<a name="client"></a>
-## Creating the client
-
-In this section, we'll look at creating a Ruby client for our `RouteGuide` service. You can see our complete example client code in [route_guide_client.rb](route_guide_client.rb).
-
-### Creating a stub
-
-To call service methods, we first need to create a *stub*.
-
-We use the `Stub` class of the `RouteGuide` module generated from our .proto.
-
-```ruby
- stub = RouteGuide::Stub.new('localhost:50051')
-```
-
-### Calling service methods
-
-Now let's look at how we call our service methods. Note that the gRPC Ruby only provides *blocking/synchronous* versions of each method: this means that the RPC call waits for the server to respond, and will either return a response or raise an exception.
-
-#### Simple RPC
-
-Calling the simple RPC `GetFeature` is nearly as straightforward as calling a local method.
-
-```ruby
-GET_FEATURE_POINTS = [
- Point.new(latitude: 409_146_138, longitude: -746_188_906),
- Point.new(latitude: 0, longitude: 0)
-]
-..
- GET_FEATURE_POINTS.each do |pt|
- resp = stub.get_feature(pt)
- ...
- p "- found '#{resp.name}' at #{pt.inspect}"
- end
-```
-
-As you can see, we create and populate a request protocol buffer object (in our case `Point`), and create a response protocol buffer object for the server to fill in. Finally, we call the method on the stub, passing it the context, request, and response. If the method returns `OK`, then we can read the response information from the server from our response object.
-
-
-#### Streaming RPCs
-
-Now let's look at our streaming methods. If you've already read [Creating the server](#server) some of this may look very familiar - streaming RPCs are implemented in a similar way on both sides. Here's where we call the server-side streaming method `list_features`, which returns an `Enumerable` of `Features`
-
-```ruby
- resps = stub.list_features(LIST_FEATURES_RECT)
- resps.each do |r|
- p "- found '#{r.name}' at #{r.location.inspect}"
- end
-```
-
-The client-side streaming method `record_route` is similar, except there we pass the server an `Enumerable`.
-
-```ruby
- ...
- reqs = RandomRoute.new(features, points_on_route)
- resp = stub.record_route(reqs.each, deadline)
- ...
-```
-
-Finally, let's look at our bidirectional streaming RPC `route_chat`. In this case, we pass `Enumerable` to the method and get back an `Enumerable`.
-
-```ruby
- resps = stub.route_chat(ROUTE_CHAT_NOTES)
- resps.each { |r| p "received #{r.inspect}" }
-```
-
-Although it's not shown well by this example, each enumerable is independent of the other - both the client and server can read and write in any order — the streams operate completely independently.
-
-## Try it out!
-
-Build client and server:
-
-```shell
-$ # from examples/ruby
-$ gem install bundler && bundle install
-```
-Run the server, which will listen on port 50051:
-```shell
-$ # from examples/ruby
-$ bundle exec route_guide/route_guide_server.rb ../node/route_guide/route_guide_db.json &
-```
-Run the client (in a different terminal):
-```shell
-$ # from examples/ruby
-$ bundle exec route_guide/route_guide_client.rb ../node/route_guide/route_guide_db.json &
-```
+The files in this folder are the samples used in [gRPC Basics: Ruby][],
+a detailed tutorial for using gRPC in Ruby.
+[gRPC Basics: Ruby]:http://www.grpc.io/docs/tutorials/basic/ruby.html
diff --git a/examples/ruby/route_guide/route_guide_client.rb b/examples/ruby/route_guide/route_guide_client.rb
index 181623a68a..baef0e502b 100755
--- a/examples/ruby/route_guide/route_guide_client.rb
+++ b/examples/ruby/route_guide/route_guide_client.rb
@@ -40,7 +40,7 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'route_guide_services'
-include Examples
+include Routeguide
GET_FEATURE_POINTS = [
Point.new(latitude: 409_146_138, longitude: -746_188_906),
diff --git a/examples/ruby/route_guide/route_guide_server.rb b/examples/ruby/route_guide/route_guide_server.rb
index 2b2b8084ef..bebe49b3be 100755
--- a/examples/ruby/route_guide/route_guide_server.rb
+++ b/examples/ruby/route_guide/route_guide_server.rb
@@ -42,7 +42,7 @@ require 'grpc'
require 'multi_json'
require 'route_guide_services'
-include Examples
+include Routeguide
COORD_FACTOR = 1e7
RADIUS = 637_100
@@ -202,10 +202,10 @@ def main
feature_db = Hash[raw_data.map { |x| [x['location'], x['name']] }]
port = '0.0.0.0:50051'
s = GRPC::RpcServer.new
- s.add_http2_port(port)
+ s.add_http2_port(port, :this_port_is_insecure)
GRPC.logger.info("... running insecurely on #{port}")
s.handle(ServerImpl.new(feature_db))
- s.run
+ s.run_till_terminated
end
main