1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) ZeroC, Inc. All rights reserved.
using System.Collections.Generic;
using System.Threading.Tasks;
using ZeroC.Test;
namespace ZeroC.Ice.Test.ProtocolBridging
{
public class Server : TestHelper
{
public override async Task RunAsync(string[] args)
{
await Communicator.ActivateAsync();
Communicator.SetProperty("TestAdapterForwarder.Endpoints", GetTestEndpoint(0));
var ice1Endpoint = TestHelper.GetTestEndpoint(
new Dictionary<string, string>
{
["Test.Host"] = Communicator.GetProperty("Test.Host")!,
["Test.Protocol"] = "ice1",
["Test.Transport"] = Communicator.GetProperty("Test.Transport")!,
},
ephemeral: true);
var ice2Endpoint = TestHelper.GetTestEndpoint(
new Dictionary<string, string>
{
["Test.Host"] = Communicator.GetProperty("Test.Host")!,
["Test.Protocol"] = "ice2",
["Test.Transport"] = Communicator.GetProperty("Test.Transport")!,
},
ephemeral: true);
if (Protocol == Protocol.Ice1)
{
Communicator.SetProperty("TestAdapterSame.Endpoints", ice1Endpoint);
Communicator.SetProperty("TestAdapterOther.Endpoints", ice2Endpoint);
}
else
{
Communicator.SetProperty("TestAdapterSame.Endpoints", ice2Endpoint);
Communicator.SetProperty("TestAdapterOther.Endpoints", ice1Endpoint);
}
ObjectAdapter adapterForwarder = Communicator.CreateObjectAdapter("TestAdapterForwarder");
ObjectAdapter adapterSame = Communicator.CreateObjectAdapter("TestAdapterSame");
ObjectAdapter adapterOther = Communicator.CreateObjectAdapter("TestAdapterOther");
ITestIntfPrx samePrx = adapterSame.Add("TestSame", new TestI(), ITestIntfPrx.Factory);
ITestIntfPrx otherPrx = adapterOther.Add("TestOther", new TestI(), ITestIntfPrx.Factory);
adapterForwarder.Add("ForwardSame", new Forwarder(samePrx));
adapterForwarder.Add("ForwardOther", new Forwarder(otherPrx));
await adapterForwarder.ActivateAsync();
await adapterSame.ActivateAsync();
await adapterOther.ActivateAsync();
ServerReady();
await Communicator.ShutdownComplete;
}
public static async Task<int> Main(string[] args)
{
await using var communicator = CreateCommunicator(ref args);
return await RunTestAsync<Server>(communicator, args);
}
}
}
|