aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/csharp/route_guide/RouteGuideServer
diff options
context:
space:
mode:
Diffstat (limited to 'examples/csharp/route_guide/RouteGuideServer')
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/Program.cs46
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs54
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs153
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj90
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/packages.config9
5 files changed, 0 insertions, 352 deletions
diff --git a/examples/csharp/route_guide/RouteGuideServer/Program.cs b/examples/csharp/route_guide/RouteGuideServer/Program.cs
deleted file mode 100644
index 4548ddf8e7..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/Program.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2015 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using Grpc.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Routeguide
-{
- class Program
- {
- static void Main(string[] args)
- {
- const int Port = 50052;
-
- 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();
- }
- }
-}
diff --git a/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs b/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 679bc4c913..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-#region Copyright notice and license
-
-// Copyright 2015 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#endregion
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("RouteGuideServer")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RouteGuideServer")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("908bdeef-05cc-42bf-9498-c4c573df8925")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs b/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
deleted file mode 100644
index f157ca08ab..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2015 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Grpc.Core;
-using Grpc.Core.Utils;
-
-namespace Routeguide
-{
- /// <summary>
- /// Example implementation of RouteGuide server.
- /// </summary>
- public class RouteGuideImpl : RouteGuide.RouteGuideBase
- {
- readonly List<Feature> features;
- readonly object myLock = new object();
- readonly Dictionary<Point, List<RouteNote>> routeNotes = new Dictionary<Point, List<RouteNote>>();
-
- public RouteGuideImpl(List<Feature> features)
- {
- this.features = features;
- }
-
- /// <summary>
- /// Gets the feature at the requested point. If no feature at that location
- /// exists, an unnammed feature is returned at the provided location.
- /// </summary>
- public override Task<Feature> GetFeature(Point request, ServerCallContext context)
- {
- return Task.FromResult(CheckFeature(request));
- }
-
- /// <summary>
- /// Gets all features contained within the given bounding rectangle.
- /// </summary>
- public override async Task ListFeatures(Rectangle request, IServerStreamWriter<Feature> responseStream, ServerCallContext context)
- {
- var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
- foreach (var response in responses)
- {
- await responseStream.WriteAsync(response);
- }
- }
-
- /// <summary>
- /// Gets a stream of points, and responds with statistics about the "trip": number of points,
- /// number of known features visited, total distance traveled, and total time spent.
- /// </summary>
- public override async Task<RouteSummary> RecordRoute(IAsyncStreamReader<Point> requestStream, 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)
- };
- }
-
- /// <summary>
- /// Receives a stream of message/location pairs, and responds with a stream of all previous
- /// messages at each of those locations.
- /// </summary>
- public override async Task RouteChat(IAsyncStreamReader<RouteNote> requestStream, IServerStreamWriter<RouteNote> responseStream, 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);
- }
- }
- }
-
- /// <summary>
- /// Adds a note for location and returns a list of pre-existing notes for that location (not containing the newly added note).
- /// </summary>
- private List<RouteNote> AddNoteForLocation(Point location, RouteNote note)
- {
- lock (myLock)
- {
- List<RouteNote> notes;
- if (!routeNotes.TryGetValue(location, out notes)) {
- notes = new List<RouteNote>();
- routeNotes.Add(location, notes);
- }
- var preexistingNotes = new List<RouteNote>(notes);
- notes.Add(note);
- return preexistingNotes;
- }
- }
-
- /// <summary>
- /// Gets the feature at the given point.
- /// </summary>
- /// <param name="location">the location to check</param>
- /// <returns>The feature object at the point Note that an empty name indicates no feature.</returns>
- private Feature CheckFeature(Point location)
- {
- var result = features.FirstOrDefault((feature) => feature.Location.Equals(location));
- if (result == null)
- {
- // No feature was found, return an unnamed feature.
- return new Feature { Name = "", Location = location };
- }
- return result;
- }
- }
-}
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
deleted file mode 100644
index 4d9d9d74f2..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{4B7C7794-BE24-4477-ACE7-18259EB73D27}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>RouteGuideServer</RootNamespace>
- <AssemblyName>RouteGuideServer</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>
- </NuGetPackageImportStamp>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
- <Private>True</Private>
- </Reference>
- <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
- <Private>True</Private>
- </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" />
- <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
- <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
- <Private>True</Private>
- </Reference>
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="RouteGuideImpl.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="packages.config" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\RouteGuide\RouteGuide.csproj">
- <Project>{49954d9c-5f17-4662-96b2-73be833dd81a}</Project>
- <Name>RouteGuide</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
- <PropertyGroup>
- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
- </PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
- </Target>
- <!-- 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">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config
deleted file mode 100644
index 2bb1f0d0bf..0000000000
--- a/examples/csharp/route_guide/RouteGuideServer/packages.config
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
- <package id="Grpc" version="1.8.0" targetFramework="net45" />
- <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
- <package id="Grpc.Tools" version="1.8.0" targetFramework="net45" />
- <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
- <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
-</packages> \ No newline at end of file