summaryrefslogtreecommitdiff
path: root/csharp/test/Ice/info/TestI.cs
blob: fdc7547b73af722ee25dfb6282374e8075440986 (plain)
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
70
71
72
73
74
75
76
77
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

using Test;
using System.Collections.Generic;

public class TestI : TestIntfDisp_
{
    override public void shutdown(Ice.Current current)
    {
        current.adapter.getCommunicator().shutdown();
    }

    override public Dictionary<string, string> getEndpointInfoAsContext(Ice.Current c)
    {
        Dictionary<string, string> ctx = new Dictionary<string, string>();
        Ice.EndpointInfo info = c.con.getEndpoint().getInfo();
        ctx["timeout"] = info.timeout.ToString();
        ctx["compress"] = info.compress ? "true" : "false";
        ctx["datagram"] = info.datagram() ? "true" : "false";
        ctx["secure"] = info.datagram() ? "true" : "false";
        ctx["type"] = info.type().ToString();

        Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info;
        ctx["host"] = ipinfo.host;
        ctx["port"] = ipinfo.port.ToString();

        if(ipinfo is Ice.UDPEndpointInfo)
        {
            Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)ipinfo;
            ctx["mcastInterface"] = udp.mcastInterface;
            ctx["mcastTtl"] = udp.mcastTtl.ToString();
        }

        return ctx;
    }

    override public Dictionary<string, string> getConnectionInfoAsContext(Ice.Current c)
    {
        Dictionary<string, string> ctx = new Dictionary<string, string>();
        Ice.ConnectionInfo info = c.con.getInfo();
        ctx["adapterName"] = info.adapterName;
        ctx["incoming"] = info.incoming ? "true" : "false";

        Ice.IPConnectionInfo ipinfo = (Ice.IPConnectionInfo)info;
        ctx["localAddress"] = ipinfo.localAddress;
        ctx["localPort"] = ipinfo.localPort.ToString();
        ctx["remoteAddress"] = ipinfo.remoteAddress;
        ctx["remotePort"] = ipinfo.remotePort.ToString();

        if(info is Ice.WSConnectionInfo)
        {
            Ice.WSConnectionInfo wsinfo = (Ice.WSConnectionInfo)info;
            foreach(KeyValuePair<string, string> e in wsinfo.headers)
            {
                ctx["ws." + e.Key] = e.Value;
            }
        }

        if(info is IceSSL.WSSConnectionInfo)
        {
            IceSSL.WSSConnectionInfo wssinfo = (IceSSL.WSSConnectionInfo)info;
            foreach(KeyValuePair<string, string> e in wssinfo.headers)
            {
                ctx["ws." + e.Key] = e.Value;
            }
        }

        return ctx;
    }
}