summaryrefslogtreecommitdiff
path: root/cs/test/Ice/invoke/BlobjectI.cs
blob: e11d2a54a3fb190a12440d37336e973f7a7dc12a (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// **********************************************************************
//
// Copyright (c) 2003-2009 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.
//
// **********************************************************************

public class BlobjectI : Ice.Blobject
{
    public override bool
    ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
    {
        Ice.Communicator communicator = current.adapter.getCommunicator();
        Ice.InputStream inS = Ice.Util.createInputStream(communicator, inParams);
        Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
        if(current.operation.Equals("opOneway"))
        {
            outParams = new byte[0];
            return true;
        }
        else if(current.operation.Equals("opString"))
        {
            string s = inS.readString();
            outS.writeString(s);
            outS.writeString(s);
            outParams = outS.finished();
            return true;
        }
        else if(current.operation.Equals("opException"))
        {
            Test.MyException ex = new Test.MyException();
            outS.writeException(ex);
            outParams = outS.finished();
            return false;
        }
        else if(current.operation.Equals("shutdown"))
        {
            communicator.shutdown();
            outParams = null;
            return true;
        }
        else if(current.operation.Equals("ice_isA"))
        {
            string s = inS.readString();
            if(s.Equals("::Test::MyClass"))
            {
                outS.writeBool(true);
            }
            else
            {
                outS.writeBool(false);
            }
            outParams = outS.finished();
            return true;
        }
        else
        {
            Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
            ex.id = current.id;
            ex.facet = current.facet;
            ex.operation = current.operation;
            throw ex;
        }
    }
}

public class BlobjectAsyncI : Ice.BlobjectAsync
{
    public override void
    ice_invoke_async(Ice.AMD_Object_ice_invoke cb, byte[] inParams, Ice.Current current)
    {
        Ice.Communicator communicator = current.adapter.getCommunicator();
        Ice.InputStream inS = Ice.Util.createInputStream(communicator, inParams);
        Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
        if(current.operation.Equals("opOneway"))
        {
            cb.ice_response(true, new byte[0]);
        }
        else if(current.operation.Equals("opString"))
        {
            string s = inS.readString();
            outS.writeString(s);
            outS.writeString(s);
            cb.ice_response(true, outS.finished());
        }
        else if(current.operation.Equals("opException"))
        {
            Test.MyException ex = new Test.MyException();
            outS.writeException(ex);
            cb.ice_response(false, outS.finished());
        }
        else if(current.operation.Equals("shutdown"))
        {
            communicator.shutdown();
            cb.ice_response(true, null);
        }
        else if(current.operation.Equals("ice_isA"))
        {
            string s = inS.readString();
            if(s.Equals("::Test::MyClass"))
            {
                outS.writeBool(true);
            }
            else
            {
                outS.writeBool(false);
            }
            cb.ice_response(true, outS.finished());
        }
        else
        {
            Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
            ex.id = current.id;
            ex.facet = current.facet;
            ex.operation = current.operation;
            throw ex;
        }
    }
}