Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2273)

Unified Diff: third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs b/third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
similarity index 61%
copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
copy to third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
index bd408470929bf250b7f0104f34209198dc0fda63..79f421df9e1f4743a2ad5930a8218e51019f6f47 100644
--- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
+++ b/third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
@@ -1,7 +1,5 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+// Copyright 2015, Google Inc.
+// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,33 +26,41 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
using System;
-using System.Collections;
-using System.Reflection;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Helloworld;
-namespace Google.Protobuf.Reflection
+namespace GreeterServer
{
- /// <summary>
- /// Accessor for repeated fields.
- /// </summary>
- internal sealed class RepeatedFieldAccessor : FieldAccessorBase
+ class GreeterImpl : Greeter.IGreeter
{
- internal RepeatedFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
+ // Server side handler of the SayHello RPC
+ public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
+ return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
}
+ }
- public override void Clear(IMessage message)
- {
- IList list = (IList) GetValue(message);
- list.Clear();
- }
+ class Program
+ {
+ const int Port = 50051;
- public override void SetValue(IMessage message, object value)
+ public static void Main(string[] args)
{
- throw new InvalidOperationException("SetValue is not implemented for repeated fields");
- }
+ Server server = new Server
+ {
+ Services = { Greeter.BindService(new GreeterImpl()) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+ };
+ server.Start();
+
+ Console.WriteLine("Greeter server listening on port " + Port);
+ Console.WriteLine("Press any key to stop the server...");
+ Console.ReadKey();
+ server.ShutdownAsync().Wait();
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698