-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2072caf
commit 1b917a6
Showing
11 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- Copy the PDBs from the NuGet packages to get file names and line numbers in stack traces. --> | ||
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<SliceCompile Include="../slice/Greeter.ice" /> | ||
<PackageReference Include="zeroc.ice.net" Version="3.8.0-alpha0" /> | ||
<PackageReference Include="zeroc.icebuilder.msbuild" Version="5.0.9" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
// Slice module VisitorCenter in Greeter.ice maps to C# namespace VisitorCenter. | ||
using VisitorCenter; | ||
|
||
// Create an Ice communicator to initialize the Ice runtime. The communicator is disposed before the program exits. | ||
using Ice.Communicator communicator = Ice.Util.initialize(ref args); | ||
|
||
// GreeterPrx is a class generated by the Slice compiler. We create a proxy from a communicator and a "stringified | ||
// proxy" with the address of the target object. | ||
// If you run the server on a different computer, replace localhost in the string below with the server's hostname | ||
// or IP address. | ||
GreeterPrx greeter = GreeterPrxHelper.createProxy(communicator, "greeter:tcp -h localhost -p 4061"); | ||
|
||
// Send a request to the remote object and get the response. | ||
// TODO: remap to GreetAsync with cs:identifier | ||
string greeting = await greeter.greetAsync(Environment.UserName); | ||
|
||
Console.WriteLine(greeting); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33122.133 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{BBF1199A-46A4-4AE9-AFFE-4D8DD59EB874}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{527EEA4D-77B9-4252-A2CD-C641A25CAD53}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FBDAF448-665A-4595-98D3-4538C56A666D}" | ||
ProjectSection(SolutionItems) = preProject | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BBF1199A-46A4-4AE9-AFFE-4D8DD59EB874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BBF1199A-46A4-4AE9-AFFE-4D8DD59EB874}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BBF1199A-46A4-4AE9-AFFE-4D8DD59EB874}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BBF1199A-46A4-4AE9-AFFE-4D8DD59EB874}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{527EEA4D-77B9-4252-A2CD-C641A25CAD53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{527EEA4D-77B9-4252-A2CD-C641A25CAD53}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{527EEA4D-77B9-4252-A2CD-C641A25CAD53}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{527EEA4D-77B9-4252-A2CD-C641A25CAD53}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0B36F1E1-0592-4A15-9981-67BC4A653EC4} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Greeter | ||
|
||
The Greeter demo illustrates how to send a request and wait for the response. | ||
|
||
You can build the client and server applications with: | ||
|
||
``` shell | ||
dotnet build | ||
``` | ||
|
||
First start the Server program: | ||
|
||
```shell | ||
cd Server | ||
dotnet run | ||
``` | ||
|
||
In a separate terminal, start the Client program: | ||
|
||
```shell | ||
cd Client | ||
dotnet run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
using VisitorCenter; | ||
|
||
namespace GreeterServer; | ||
|
||
/// <summary>A Chatbot is an Ice servant that implements Slice interface Greeter.</summary> | ||
internal class Chatbot : GreeterDisp_ | ||
{ | ||
// Implements the abstract method greet from the GreeterDisp_ class generated by the Slice compiler. | ||
public override string greet(string name, Ice.Current current) | ||
{ | ||
Console.WriteLine($"Dispatching greet request {{ name = '{name}' }}"); | ||
return $"Hello, {name}!"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
// Extends Program to provide the CancelKeyPressed property. | ||
public static partial class Program | ||
{ | ||
/// <summary>Gets a task that completes when the console receives a Ctrl+C.</summary> | ||
public static Task CancelKeyPressed => _cancelKeyPressedTcs.Task; | ||
|
||
private static readonly TaskCompletionSource _cancelKeyPressedTcs = new(); | ||
|
||
static Program() => | ||
Console.CancelKeyPress += (sender, eventArgs) => | ||
{ | ||
eventArgs.Cancel = true; | ||
_ = _cancelKeyPressedTcs.TrySetResult(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
using GreeterServer; | ||
|
||
// Create an Ice communicator to initialize the Ice runtime. The communicator is disposed before the program exits. | ||
using Ice.Communicator communicator = Ice.Util.initialize(ref args); | ||
|
||
// Create an object adapter that listens for incoming requests and dispatches them to servants. | ||
var adapter = communicator.createObjectAdapterWithEndpoints("GreeterAdapter", "tcp -p 4061"); | ||
|
||
// Register the Chatbot servant with the adapter. | ||
adapter.add(new Chatbot(), Ice.Util.stringToIdentity("greeter")); | ||
|
||
// Start dispatching requests. | ||
adapter.activate(); | ||
|
||
// Wait until the user presses Ctrl+C. | ||
await CancelKeyPressed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- Copy the PDBs from the NuGet packages to get file names and line numbers in stack traces. --> | ||
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<SliceCompile Include="../slice/Greeter.ice" /> | ||
<PackageReference Include="zeroc.ice.net" Version="3.8.0-alpha0" /> | ||
<PackageReference Include="zeroc.icebuilder.msbuild" Version="5.0.9" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
#pragma once | ||
|
||
module VisitorCenter | ||
{ | ||
/// Represents a simple greeter. | ||
interface Greeter | ||
{ | ||
/// Creates a personalized greeting. | ||
/// @param name: The name of the person to greet. | ||
/// @returns: The greeting. | ||
string greet(string name); | ||
} | ||
} |